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


Python Keys.TAB属性代码示例

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


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

示例1: lambda_handler

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def lambda_handler(*args, **kwargs):
    driver = WebDriverWrapper()

    driver.get_url('https://www.google.es/')

    driver.set_input_value('//input[@name="q"]', '21 buttons')

    button = driver.find("//input[@name='btnK']")
    button.send_keys(Keys.TAB)
    driver.click('//input[@name="btnK"]')

    first_google_result_title = driver.get_inner_html('(//div[@class="rc"]//a)[1]')

    print("--------------------------")
    print(first_google_result_title)
    print("--------------------------")

    driver.close() 
开发者ID:21Buttons,项目名称:pychromeless,代码行数:20,代码来源:lambda_function.py

示例2: proxy_authentication

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def proxy_authentication(browser, logger, proxy_username, proxy_password):
    """ Authenticate proxy using popup alert window """

    # FIXME: https://github.com/SeleniumHQ/selenium/issues/7239
    # this feauture is not working anymore due to the Selenium bug report above
    logger.warn(
        "Proxy Authentication is not working anymore due to the Selenium bug "
        "report: https://github.com/SeleniumHQ/selenium/issues/7239"
    )

    try:
        # sleep(1) is enough, sleep(2) is to make sure we
        # give time to the popup windows
        sleep(2)
        alert_popup = browser.switch_to_alert()
        alert_popup.send_keys(
            "{username}{tab}{password}{tab}".format(
                username=proxy_username, tab=Keys.TAB, password=proxy_password
            )
        )
        alert_popup.accept()
    except Exception:
        logger.warn("Unable to proxy authenticate") 
开发者ID:Instagram-Tools,项目名称:bot,代码行数:25,代码来源:browser.py

示例3: switch_tab

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def switch_tab(driver):
    main_window = driver.current_window_handle
    body = driver.find_element_by_tag_name("body")
    # body.send_keys(Keys.CONTROL + 't')
    body.send_keys(Keys.CONTROL + 't')
    driver.switch_to_window(main_window)
    body_tab = driver.find_element_by_tag_name("body")
    time.sleep(.5)
    if body == body_tab:
        logging.warning("Switch tab failed")
    else:
        body_tab.send_keys(Keys.CONTROL + Keys.TAB)
        driver.switch_to_window(main_window)
        body = driver.find_element_by_tag_name("body")
        body.send_keys(Keys.CONTROL + 'w')
        driver.switch_to_window(main_window)
        body_tab = driver.find_element_by_tag_name("body")
        body_tab.send_keys(Keys.CONTROL + Keys.TAB)
        driver.switch_to_window(main_window)
        body = driver.find_element_by_tag_name("body")
        if body != body_tab:
            logging.warning("Failed to switch tab, switch back to previous tab") 
开发者ID:iclab,项目名称:centinel,代码行数:24,代码来源:foctor_core.py

示例4: load

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def load(x,article_number):
    flag=1 # 表示尚未拉到底部
    L=0
    while(flag or L<article_number):
        L=len(x.find_elements_by_class_name('home__timeline__item'))
        try:
            x.find_element_by_class_name('home__timeline__more').click()
            flag=0
        except:
            x.find_elements_by_class_name('home__timeline__item')[-1].find_element_by_xpath('h3/a').send_keys(Keys.TAB)
    print('loaded %d articles.' % L) 
开发者ID:Coldog2333,项目名称:Financial-NLP,代码行数:13,代码来源:from_xueqiu.py

示例5: tab

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def tab(self):
        elem = self.__get_element(self.k, self.v)
        elem.send_keys(Keys.TAB) 
开发者ID:SeldomQA,项目名称:poium,代码行数:5,代码来源:page_objects.py

示例6: set_timeframe

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def set_timeframe(browser, timeframe):
    log.info('Setting timeframe to ' + timeframe)
    wait_and_click(browser, css_selectors['btn_timeframe'])
    css = css_selectors['options_timeframe']
    el_options = find_elements(browser, css)
    index = 0
    found = False
    while not found and index < len(el_options):
        if el_options[index].text == timeframe:
            el_options[index].click()
            found = True
        index += 1
    if not found:
        log.warning('Unable to set timeframe to ' + timeframe)
        raise ValueError

    if found:
        # TODO replace 'element.send_keys" with
        #  action = ActionChains(browser)
        #  action.send_keys(Keys.TAB)
        #  action.perform()
        html = find_element(browser, 'html', By.TAG_NAME)
        html.send_keys(MODIFIER_KEY + 's')
        time.sleep(DELAY_BREAK)

    return found 
开发者ID:timelyart,项目名称:Kairos,代码行数:28,代码来源:tv.py

示例7: tab

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def tab(self):
            self.elem.send_keys(Keys.TAB) 
开发者ID:SeldomQA,项目名称:seldom,代码行数:4,代码来源:webdriver.py

示例8: focus_on_caption_line

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def focus_on_caption_line(_step, index):
    world.wait_for_present('.video.is-captions-rendered')
    world.wait_for(lambda _: world.css_text('.subtitles'), timeout=30)
    find_caption_line_by_data_index(int(index.strip()))._element.send_keys(Keys.TAB) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:6,代码来源:video.py

示例9: set_element_value

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def set_element_value(element_css, element_value, key=None):
    element = world.css_find(element_css).first
    element.fill(element_value)
    # hit TAB or provided key to trigger save content
    if key is not None:
        element._element.send_keys(getattr(Keys, key))  # pylint: disable=protected-access
    else:
        element._element.send_keys(Keys.TAB)  # pylint: disable=protected-access 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:10,代码来源:common.py

示例10: set_field_value

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def set_field_value(index, value):
    """
    Set the field to the specified value.

    Note: we cannot use css_fill here because the value is not set
    until after you move away from that field.
    Instead we will find the element, set its value, then hit the Tab key
    to get to the next field.
    """
    elem = world.css_find('.metadata_edit div.wrapper-comp-setting input.setting-input')[index]
    elem.value = value
    elem.type(Keys.TAB) 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:14,代码来源:component_settings_editor_helpers.py

示例11: _test_skip_link

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def _test_skip_link(self, test_url):
        active_element = self.driver.switch_to.active_element
        skip_link = self.page.q(css='.skip-link').results[0]
        skip_link_ref = '#' + skip_link.get_attribute('href').split('#')[-1]
        target_element = self.page.q(css=skip_link_ref)
        self.assertEqual(len(target_element), 1)

        active_element.send_keys(Keys.TAB)
        active_element = self.driver.switch_to.active_element
        active_element.send_keys(Keys.ENTER)

        if test_url:
            url_hash = self.driver.execute_script('return window.location.hash;')
            self.assertEqual(url_hash, skip_link_ref) 
开发者ID:edx,项目名称:edx-analytics-dashboard,代码行数:16,代码来源:mixins.py

示例12: test_create

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def test_create(self):
        driver = self.selenium
        driver.get("{}{}".format(self.live_server_url, reverse('issue:create',
                                                               kwargs={'project': self.project.name_short})))

        title = "title"
        driver.find_element_by_id("id_title").send_keys(title)

        # assert that initially selected kanbancol is 'Todo'
        self.assertEqual(Select(driver.find_element_by_id("id_kanbancol")).first_selected_option.text, "Todo")

        # assert that project has 4 (3 default + --- line) kanban colums
        self.assertEqual(len(Select(driver.find_element_by_id("id_kanbancol")).options), 4)

        Select(driver.find_element_by_id("id_kanbancol")).select_by_visible_text("Todo")
        driver.find_element_by_name("due_date").click()
        driver.find_element_by_name("due_date").send_keys(str(datetime.date.today().strftime("%m/%d/%Y")))
        driver.find_element_by_name("due_date").send_keys(Keys.TAB)  # close datepicker
        # assert that we have one assignee in selection field
        driver.find_element_by_css_selector("input.select2-search__field").click()
        self.assertEqual(len(driver.find_elements_by_css_selector('#select2-id_assignee-results li')), 1)
        driver.find_element_by_css_selector("input.select2-search__field").send_keys(Keys.ESCAPE)
        Select(driver.find_element_by_id("id_priority")).select_by_visible_text("High")
        driver.find_element_by_id("id_storypoints").clear()
        driver.find_element_by_id("id_storypoints").send_keys("2")

        # assert that project has no related issues to choose from (only one issue present in proj2)
        # one item present: No items found
        driver.find_element_by_xpath("(//input[@type='search'])[2]").send_keys(Keys.RETURN)
        time.sleep(1)
        self.assertEqual(len(driver.find_elements_by_css_selector('#select2-id_dependsOn-results li')), 1)
        for i in driver.find_elements_by_css_selector('#select2-id_dependsOn-results li'):
            self.assertEqual(i.text, "No results found")

        driver.find_element_by_id("wmd-input-id_description").clear()
        driver.find_element_by_id("wmd-input-id_description").send_keys("blubber")
        driver.find_element_by_id("id_submit_create").click()
        self.assertIn(title, driver.page_source) 
开发者ID:iguana-project,项目名称:iguana,代码行数:40,代码来源:test_create_and_edit.py

示例13: test_tabbing

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def test_tabbing(browser, port):
    _load_notebook(browser, port)
    _activate_toolbar(browser)

    def active_element_is(class_name):
        def waitfor(browser):
            elem = browser.execute_script("return document.activeElement")
            return elem.get_attribute("class") == class_name
        return waitfor

    # make it manually graded
    _select_manual(browser)

    # click the id field
    element = browser.find_element_by_css_selector(".nbgrader-points-input")
    # There is a bug where sometimes the click doesn't register, so we also press enter
    # here which for some reason seems to help. It's not clear here what's happening
    # to cause this bug but see https://github.com/mozilla/geckodriver/issues/322 for
    # reference. It only seemed to be a problem on Linux, not Mac or Windows.
    element.click()
    element.send_keys(Keys.RETURN)
    _wait(browser).until(active_element_is("nbgrader-points-input"))

    # press tab and check that the active element is correct
    element.send_keys(Keys.TAB)
    _wait(browser).until(active_element_is("nbgrader-id-input"))

    # make it autograder tests
    _select_tests(browser)

    # click the id field
    element = browser.find_element_by_css_selector(".nbgrader-points-input")
    element.click()
    element.send_keys(Keys.RETURN)
    _wait(browser).until(active_element_is("nbgrader-points-input"))

    # press tab and check that the active element is correct
    element.send_keys(Keys.TAB)
    _wait(browser).until(active_element_is("nbgrader-id-input")) 
开发者ID:jupyter,项目名称:nbgrader,代码行数:41,代码来源:test_create_assignment.py

示例14: press_tab

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def press_tab(self) -> Element:
        return self.press(Keys.TAB) 
开发者ID:yashaka,项目名称:selene,代码行数:4,代码来源:entity.py

示例15: set_expiration

# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import TAB [as 别名]
def set_expiration(browser, _alert_dialog, alert_config):
    max_minutes = 86400
    datetime_format = '%Y-%m-%d %H:%M'

    exp = alert_config['expiration']
    if type(exp) is int:
        alert_config['expiration'] = dict()
        alert_config['expiration']['time'] = exp
        alert_config['expiration']['open-ended'] = False
    else:
        if 'time' not in alert_config['expiration']:
            alert_config['expiration']['time'] = exp
        if 'open-ended' not in alert_config['expiration']:
            alert_config['expiration']['open-ended'] = False

    checkbox = find_element(_alert_dialog, css_selectors['checkbox_dlg_create_alert_open_ended'])
    if is_checkbox_checked(checkbox) != alert_config['expiration']['open-ended']:
        wait_and_click(_alert_dialog, css_selectors['clickable_dlg_create_alert_open_ended'])

    if alert_config['expiration']['open-ended'] or str(alert_config['expiration']['time']).strip() == '' or str(alert_config['expiration']['time']).strip().lower().startswith('n') or type(alert_config['expiration']['time']) is None:
        return
    elif type(alert_config['expiration']['time']) is int:
        target_date = datetime.datetime.now() + datetime.timedelta(minutes=float(alert_config['expiration']['time']))
    elif type(alert_config['expiration']['time']) is str and len(str(alert_config['expiration']['time']).strip()) > 0:
        target_date = datetime.datetime.strptime(str(alert_config['expiration']['time']).strip(), datetime_format)
    else:
        return

    max_expiration = datetime.datetime.now() + datetime.timedelta(minutes=float(max_minutes - 1440))
    if target_date > max_expiration:
        target_date = max_expiration
    date_value = target_date.strftime('%Y-%m-%d')
    time_value = target_date.strftime('%H:%M')

    # For some reason TV does not register setting the date value directly.
    # Furthermore, we need to make sure that the date and time inputs are cleared beforehand.
    input_date = find_element(alert_dialog, 'alert_exp_date', By.NAME)
    clear(input_date)
    set_value(browser, input_date, date_value, False, True)
    input_time = find_element(_alert_dialog, 'alert_exp_time', By.NAME)
    time.sleep(DELAY_BREAK_MINI)
    clear(input_time)
    set_value(browser, input_time, time_value, False, True)
    send_keys(input_time, Keys.TAB)
    time.sleep(DELAY_BREAK_MINI) 
开发者ID:timelyart,项目名称:Kairos,代码行数:47,代码来源:tv.py


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