當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。