当前位置: 首页>>代码示例>>Python>>正文


Python Keys.RETURN属性代码示例

本文整理汇总了Python中selenium.webdriver.common.keys.Keys.RETURN属性的典型用法代码示例。如果您正苦于以下问题:Python Keys.RETURN属性的具体用法?Python Keys.RETURN怎么用?Python Keys.RETURN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在selenium.webdriver.common.keys.Keys的用法示例。


在下文中一共展示了Keys.RETURN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_usr_reg

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def test_usr_reg(self):
        self.browser.get(self.live_server_url+reverse('niji:index'))
        self.browser.find_element_by_link_text("Reg").click()
        self.assertEqual(self.browser.current_url, self.live_server_url+reverse("niji:reg"))
        username = self.browser.find_element_by_name('username')
        email = self.browser.find_element_by_name('email')
        password1 = self.browser.find_element_by_name('password1')
        password2 = self.browser.find_element_by_name('password2')
        username.send_keys("test3")
        password1.send_keys("333")
        password2.send_keys("333")
        email.send_keys("test3@example.com")
        password1.send_keys(Keys.RETURN)
        self.assertEqual(self.browser.current_url, self.live_server_url+reverse("niji:index"))
        self.assertIn("Log out", self.browser.page_source)
        self.assertIn("test3", self.browser.page_source) 
开发者ID:ericls,项目名称:niji,代码行数:18,代码来源:tests.py

示例2: perform_search

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def perform_search(driver, search_terms, options):
    if "www.google.com" not in driver.current_url:
        go_to_google_main_page(driver)   # sites like Twitter break back button

    search_locator = "gbqfq"
    search_box = driver.find_element_by_id(search_locator)
    search_box.clear()

    terms_string = ""
    max_terms = random.randrange(2, options.max_search_terms + 1)
    for i in range(max_terms):
        terms_string += search_terms[i] + " "
    terms_string = terms_string.rstrip()

    search_box.send_keys(terms_string)
    search_box.send_keys(Keys.RETURN)
    random_delay(options) 
开发者ID:aaronshaver,项目名称:google-privacy-enhancer,代码行数:19,代码来源:script.py

示例3: login

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def login(self):
        """login to linkedin then wait 3 seconds for page to load"""
        # Enter login credentials
        WebDriverWait(self.driver, 120).until(
            EC.element_to_be_clickable(
                (By.ID, "session_key-login")
            )
        )
        elem = self.driver.find_element_by_id("session_key-login")
        elem.send_keys(self.username)
        elem = self.driver.find_element_by_id("session_password-login")
        elem.send_keys(self.password)
        # Enter credentials with Keys.RETURN
        elem.send_keys(Keys.RETURN)
        # Wait a few seconds for the page to load
        time.sleep(3) 
开发者ID:kirkhunter,项目名称:linkedin-jobs-scraper,代码行数:18,代码来源:client.py

示例4: enter_search_keys

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def enter_search_keys(self):
        """
        execute the job search by entering job and location information.
        The location is pre-filled with text, so we must clear it before
        entering our search.
        """
        driver = self.driver
        WebDriverWait(driver, 120).until(
            EC.presence_of_element_located(
                (By.ID, "keyword-search-box")
            )
        )
        # Enter search criteria
        elem = driver.find_element_by_id("keyword-search-box")
        elem.send_keys(self.keyword)
        # clear the text in the location box then enter location
        elem = driver.find_element_by_id("location-search-box").clear()
        elem = driver.find_element_by_id("location-search-box")
        elem.send_keys(self.location)
        elem.send_keys(Keys.RETURN)
        time.sleep(3) 
开发者ID:kirkhunter,项目名称:linkedin-jobs-scraper,代码行数:23,代码来源:client.py

示例5: test_login

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def test_login(self):
        if self.browser == 'android':
            raise unittest.SkipTest("The popup doesn't open in the webview.")
        self.get('/')
        self.wait_for_element('btn-login', By.CLASS_NAME)
        self.click(self.drv.find_elements_by_class_name('btn-login')[-1])
        self.sleep()
        self.switch_window()
        self.wait_for_element('authentication_email', visible=True)
        (
            self.drv
            .find_element_by_id('authentication_email')
            .send_keys('test@mockmyid.com', Keys.RETURN)
        )
        self.switch_window(go_back=True)
        self.wait_for_element('UserDropdown', timeout=10)
        self.assertIn('Recent Submissions', self.drv.page_source) 
开发者ID:SEL-Columbia,项目名称:dokomoforms,代码行数:19,代码来源:test_selenium.py

示例6: create_new_workflow

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def create_new_workflow(self, wname, wdesc=''):
        # Create the workflow
        self.selenium.find_element_by_class_name(
            'js-create-workflow').click()
        self.wait_for_modal_open()

        self.selenium.find_element_by_id('id_name').send_keys(wname)
        desc = self.selenium.find_element_by_id('id_description_text')
        desc.send_keys(wdesc)
        desc.send_keys(Keys.RETURN)

        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//table[@id="dataops-table"]')
            )
        ) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:18,代码来源:__init__.py

示例7: create_new_action_out_basic

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def create_new_action_out_basic(self, aname, action_type, adesc=''):
        # click on the create action button
        self.selenium.find_element_by_class_name('js-create-action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_name')))

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys(aname)
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(action_type)
        desc.send_keys(adesc)
        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="action-out-editor"]')
            )
        ) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:26,代码来源:__init__.py

示例8: create_new_survey_action

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def create_new_survey_action(self, aname, adesc=''):
        # click on the create action button
        self.selenium.find_element_by_class_name('js-create-action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_name')))

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys(aname)
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(models.Action.SURVEY)
        desc.send_keys(adesc)
        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="action-in-editor"]')
            )
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        ) 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:26,代码来源:__init__.py

示例9: get_application

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def get_application(self, appname):
        self.check_page_contains_error()
        e = wait_for_xpath_presence(
            self.driver, cfg_applications_xpath, be_clickable=True)
        e.click()
        e = wait_for_xpath_presence(self.driver, cfg_searchbox_xpath)
        e.send_keys(appname)
        e.send_keys(Keys.RETURN)
        time.sleep(1)
        self.driver.save_screenshot(join(
            cfg_output_files_path,
            "applications.png"))
        app_xpath = "//a[contains (.,'" + appname + "')]"
        e = wait_for_xpath_presence(self.driver, app_xpath)
        e.click()
        time.sleep(1)
        logging.info("- Searched for application: {}".format(appname)) 
开发者ID:target,项目名称:winnaker,代码行数:19,代码来源:models.py

示例10: test_filter

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def test_filter(self):
        # Wait until baton is ready
        wait = WebDriverWait(self.driver, 10)
        wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))
        time.sleep(2)
        rows = self.driver.find_elements_by_css_selector(
            '#result_list tbody tr')
        self.assertEqual(len(rows), 3)
        filter_button = self.driver.find_element_by_css_selector(
            '.changelist-filter-toggler')
        filter_button.click()
        input = self.driver.find_element_by_css_selector(
            '#changelist-filter-modal input')
        input.send_keys('super')
        input.send_keys(Keys.RETURN)
        rows = self.driver.find_elements_by_css_selector(
            '#result_list tbody tr')
        self.assertEqual(len(rows), 2) 
开发者ID:otto-torino,项目名称:django-baton,代码行数:20,代码来源:test_e2e_input_filter.py

示例11: test_edit_item

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def test_edit_item(self):
        self.login()
        time.sleep(1)

        try:
            item = self.client.find_element_by_xpath("//span[text()='test item 1']")
            item_body = 'test item 1'
        except NoSuchElementException:
            item = self.client.find_element_by_xpath("//span[text()='test item 2']")
            item_body = 'test item 2'

        hover_item = ActionChains(self.client).move_to_element(item)
        hover_item.perform()
        edit_button = self.client.find_element_by_class_name('edit-btn')
        edit_button.click()
        edit_item_input = self.client.find_element_by_id('edit-item-input')
        edit_item_input.send_keys(' edited')
        edit_item_input.send_keys(Keys.RETURN)
        time.sleep(1)
        self.assertIn('%s edited' % item_body, self.client.page_source) 
开发者ID:greyli,项目名称:todoism,代码行数:22,代码来源:test_ui.py

示例12: create_organization

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def create_organization(self, name, description, users):
        driver = self.driver
        driver.get(self.base_url)
        WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, 'Organizations'))).click()
        WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, 'Add Organization'))).click()
        WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, 'field-name')))

        # Wait a bit to let ckan add javascript hooks
        time.sleep(0.2)

        driver.find_element_by_id('field-name').clear()
        driver.find_element_by_id('field-name').send_keys(name)
        driver.find_element_by_id('field-description').clear()
        driver.find_element_by_id('field-description').send_keys(description)
        driver.find_element_by_name('save').click()

        # Add users
        WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, 'Manage'))).click()
        WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, 'Members'))).click()
        for user in users:
            WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, 'Add Member'))).click()
            WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "s2id_autogen1"))).send_keys(user + Keys.RETURN)
            driver.find_element_by_name('submit').click() 
开发者ID:conwetlab,项目名称:ckanext-privatedatasets,代码行数:25,代码来源:test_selenium.py

示例13: test_fuzz

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def test_fuzz(tmp_path, browser):
    # TODO ugh. this still results in 'tab permissions' pages, but perhaps because of closed tabs?
    # dunno if it's worth fixing..
    urls = {
        'https://www.iana.org/domains/reserved': 'IANA',
        'iana.org/domains/reserved': 'IANA2',
    }
    with _test_helper(tmp_path, index_urls(urls), 'https://example.com', browser=browser) as helper:
        driver = helper.driver
        tabs = 30
        for _ in range(tabs):
            driver.find_element_by_tag_name('a').send_keys(Keys.CONTROL + Keys.RETURN)

        sleep(5)
        for _ in range(tabs - 2):
            driver.close()
            sleep(0.1)
            driver.switch_to.window(driver.window_handles[0])

        def cb():
            for _ in range(10):
                send_key('Ctrl+Shift+t')
                sleep(0.1)
        trigger_callback(driver, cb)
        confirm("shouldn't result in 'unexpected error occured'; show only show single notification per page") 
开发者ID:karlicoss,项目名称:promnesia,代码行数:27,代码来源:end2end_test.py

示例14: _driver_brute

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def _driver_brute(self, username: str, pwd_guess: str) -> str:
        """
        Uses a Firefox-based webdriver in order to attempt authentication by
        spawning actual browser processes. Should be used in the situation that
        the headless run does not yield anything successful, and more visibility is needed.
        """

        # find the username input field, and send keys
        user_elem = self.browser.find_element(By.NAME, self.fields["username"])  # type: ignore
        user_elem.clear()
        user_elem.send_keys(username)

        # find the password input field, and send keys
        pwd_elem = self.browser.find_element(By.NAME, self.fields["password"])  # type: ignore
        pwd_elem.clear()
        pwd_elem.send_keys(pwd_guess)

        # press return key to attempt to auth, and wait briefly
        pwd_elem.send_keys(Keys.RETURN)
        time.sleep(2)
        return self.browser.title 
开发者ID:ex0dus-0x,项目名称:brute,代码行数:23,代码来源:web.py

示例15: __init__

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import RETURN [as 别名]
def __init__(self):
        chromedriver = "/home/dash/chromedriver"
        os.environ["webdriver.chrome.driver"] = chromedriver
        login_url = "http://weibo.com/login.php?url=http%3A%2F%2Fweibo.com%2Fu%2F3655689037%2Fhome%3Fleftnav%3D1%26wvr%3D5"
        browser = webdriver.Chrome(chromedriver)
        browser.get(login_url)
        time.sleep(5)
        usernamebox = browser.find_element_by_xpath("//div[@class='inp username']/input")  # Find the search box
        passwordbox = browser.find_element_by_xpath("//div[@class='inp password']/input")  # Find the search box
        usernamebox.send_keys('cisl20140001@126.com')
        passwordbox.send_keys('dash123456'+Keys.RETURN)
        print 'go to '
        time.sleep(8)
        print 'ready to get cookie'
        self.cookie = browser.get_cookies()
        print self.cookie; 
开发者ID:openslack,项目名称:openslack-crawler,代码行数:18,代码来源:weibo.py


注:本文中的selenium.webdriver.common.keys.Keys.RETURN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。