當前位置: 首頁>>代碼示例>>Python>>正文


Python Keys.ESCAPE屬性代碼示例

本文整理匯總了Python中selenium.webdriver.common.keys.Keys.ESCAPE屬性的典型用法代碼示例。如果您正苦於以下問題:Python Keys.ESCAPE屬性的具體用法?Python Keys.ESCAPE怎麽用?Python Keys.ESCAPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在selenium.webdriver.common.keys.Keys的用法示例。


在下文中一共展示了Keys.ESCAPE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _process_survey

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def _process_survey(self):
        """
        Validate Lego's survey form
        """

        print("* Sometimes they ask you to fill in a survey.")
        try:
            # FIXME: survey's layer escape key no longer work
            survey_layer = self.browser.find_element_by_id('ipeL104230')
            survey_layer.send_keys(Keys.ESCAPE)

            # we should click on the "no" button to close the survey window
            # no_survey_button = self.browser.find_element_by_xpath(
            #     "//area[contains(@onclick,'ipe.clWin')]")
            # no_survey_button.click()

        except NoSuchElementException:
            print("We're lucky, no survey on the LEGO shop today!") 
開發者ID:bittner,項目名稱:lego-mindstorms-ev3-comparison,代碼行數:20,代碼來源:legoshop.py

示例2: process_ad_divs

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def process_ad_divs(ad_divs, ad_count, driver, dirname, ad_limit, wait=0):
    # Add whitespace to bottom to allow scrolling to bottom row
    window_height = driver.execute_script('return window.innerHeight')
    driver.execute_script("arguments[0].setAttribute('style', 'margin-bottom:{}px;')".format(window_height),
                          ad_divs[-1])
    processed_add_divs = set()
    for ad_div in ad_divs:
        if ad_count > 0:
            sleep(wait)
        ad_count += 1
        print('Ad {}'.format(ad_count))
        screenshot(ad_div, ad_count, dirname, driver)
        # Click Ad Performance
        ad_div.find_element_by_partial_link_text('See Ad Performance').click()
        webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
        processed_add_divs.add(ad_div)
        if ad_limit == ad_count:
            break

    return processed_add_divs 
開發者ID:justinlittman,項目名稱:fb-ad-archive-scraper,代碼行數:22,代碼來源:scraper.py

示例3: _to_command_mode

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def _to_command_mode(self):
        """Changes us into command mode on currently focused cell

        """
        self.body.send_keys(Keys.ESCAPE)
        self.browser.execute_script(
            "return Jupyter.notebook.handle_command_mode("
            "Jupyter.notebook.get_cell("
            "Jupyter.notebook.get_edit_index()))") 
開發者ID:vatlab,項目名稱:sos-notebook,代碼行數:11,代碼來源:test_utils.py

示例4: test_create_project

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def test_create_project(self):
        self.selenium.get('{}{}'.format(self.live_server_url, reverse('project:create')))
        create_form = self.selenium.find_element_by_id("id_create_form")
        name = 'TestProjekt'
        create_form.find_element_by_id("id_name").send_keys(name)
        create_form.find_element_by_id("id_name_short").send_keys('TP')
        create_form.find_element_by_id("id_description").send_keys('This is a description for our TestProject')
        create_form.find_element_by_css_selector('input.select2-search__field').send_keys('te')
        # TODO TESTCASE this doesn't work on the create form - y doesn't this work?
        self.selenium.find_element_by_css_selector(
                'li.select2-results__option.select2-results__option--highlighted'
                ).click()
        create_form.find_element_by_css_selector("input.select2-search__field").send_keys(Keys.ESCAPE)
        create_form.find_element_by_id('id_submit_create').click()
        self.assertEqual(self.selenium.title, name) 
開發者ID:iguana-project,項目名稱:iguana,代碼行數:17,代碼來源:test_project.py

示例5: test_issue_modify

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def test_issue_modify(self, slackmock):
        issue = Issue()
        issue.title = self.title_name
        issue.project = self.project
        issue.save()

        self.selenium.get(
                '{}{}'.format(
                    self.live_server_url,
                    reverse('issue:edit', kwargs={'project': self.short, 'sqn_i': issue.number})
                    )
                )

        # open assignee autocomplete field
        self.selenium.find_element_by_css_selector("input.select2-search__field").click()
        # select first result
        self.selenium.find_elements_by_css_selector('#select2-id_assignee-results li')[0].click()
        # close autocomplete
        self.selenium.find_element_by_css_selector("input.select2-search__field").send_keys(Keys.ESCAPE)

        self.selenium.find_element_by_id('id_submit_edit').click()
        slackmock.chat_postMessage.assert_called_with(
            channel="channel",
            attachments=[{
                'fallback': str(self.user) + " changed issue "+self.short+"-1 "+self.title_name+".",
                'pretext': 'Issue changed:',
                'title': self.short+"-1 "+self.title_name,
                'title_link': "http://localhost:8000/project/"+self.short+"/issue/1/",
                'author_name': str(self.user),
                'author_link': "http://localhost:8000" + self.user.get_absolute_url(),
                'author_icon': "http://localhost:8000" + self.user.avatar.url,
                'fields': [{
                    'title': 'Assignee',
                    'value': ' → a',
                    'short': True,
                    }],
                'color': 'good',
            }]
        ) 
開發者ID:iguana-project,項目名稱:iguana,代碼行數:41,代碼來源:test_slack.py

示例6: test_create

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [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

示例7: _change_order_type

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def _change_order_type(self, order_type='market'):
        if order_type not in ['market', 'limit', 'stopLoss', 'stopLimit', 'trailingStop']:
            raise ValueError('Invalid order type, order_type={}'.format(order_type))

        def _select(v):
            self.driver.find_element_by_xpath(
                '//span[contains(., "{} Order")]/parent::span'
                '/parent::div/parent::div'.format(v)).click()

        # click the drop-down
        self.driver.find_elements_by_xpath(
            '//form[@data-testid="OrderForm"]/div[1]/div[1]/div')[-1].click()

        if order_type == 'market':
            _select('Market')
        elif order_type == 'limit':
            _select('Limit')
        elif order_type == 'stopLoss':
            _select('Stop Loss')
        elif order_type == 'stopLimit':
            _select('Stop Limit')
        elif order_type == 'trailingStop':
            _select('Trailing Stop')
        else:
            self.driver.find_element_by_tag_name('body').send_keys(Keys.ESCAPE)
            raise ValueError('No such order type: {}'.format(order_type)) 
開發者ID:qks1lver,項目名稱:redtide,代碼行數:28,代碼來源:api.py

示例8: test_cell_ids

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def test_cell_ids(browser, port):
    _load_notebook(browser, port)
    _activate_toolbar(browser)

    # turn it into a cell with an id
    _select_solution(browser)
    # for some reason only one call doesn't trigger on_change event
    _select_solution(browser)
    _set_id(browser, cell_id="")

    # save and check for an error (blank id)
    _save(browser)
    _wait_for_modal(browser)
    _dismiss_modal(browser)

    # set the label
    _set_id(browser)

    # create a new cell
    element = browser.find_element_by_tag_name("body")
    element.send_keys(Keys.ESCAPE)
    element.send_keys("b")

    # make sure the toolbar appeared
    def find_toolbar(browser):
        try:
            browser.find_elements_by_css_selector(".celltoolbar select")[1]
        except IndexError:
            return False
        return True
    _wait(browser).until(find_toolbar)

    # make it a test cell and set the label
    _select_tests(browser, index=1)
    _set_id(browser, index=1)

    # save and check for an error (duplicate id)
    _save(browser)
    _wait_for_modal(browser)
    _dismiss_modal(browser) 
開發者ID:jupyter,項目名稱:nbgrader,代碼行數:42,代碼來源:test_create_assignment.py

示例9: test_task_cell_ids

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def test_task_cell_ids(browser, port):
    _load_notebook(browser, port, name='task')
    _activate_toolbar(browser)

    # turn it into a cell with an id
    _select_task(browser)
    _set_id(browser, cell_id="")

    # save and check for an error (blank id)
    _save(browser)
    _wait_for_modal(browser)
    _dismiss_modal(browser)

    # set the label
    _set_id(browser)

    # create a new cell
    element = browser.find_element_by_tag_name("body")
    element.send_keys(Keys.ESCAPE)
    element.send_keys("b")

    # make sure the toolbar appeared
    def find_toolbar(browser):
        try:
            browser.find_elements_by_css_selector(".celltoolbar select")[1]
        except IndexError:
            return False
        return True
    _wait(browser).until(find_toolbar)

    # make it a test cell and set the label
    _select_task(browser, index=1)
    _set_id(browser, index=1)

    # save and check for an error (duplicate id)
    _save(browser)
    _wait_for_modal(browser)
    _dismiss_modal(browser) 
開發者ID:jupyter,項目名稱:nbgrader,代碼行數:40,代碼來源:test_create_assignment.py

示例10: _save_comment

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def _save_comment(browser, index):
    _send_keys_to_body(browser, Keys.ESCAPE)
    glyph = browser.find_elements_by_css_selector(".comment-saved")[index]
    WebDriverWait(browser, 10).until(lambda browser: glyph.is_displayed())
    WebDriverWait(browser, 10).until(lambda browser: not glyph.is_displayed()) 
開發者ID:jupyter,項目名稱:nbgrader,代碼行數:7,代碼來源:formgrade_utils.py

示例11: _save_score

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def _save_score(browser, index):
    _send_keys_to_body(browser, Keys.ESCAPE)
    glyph = browser.find_elements_by_css_selector(".score-saved")[index]
    WebDriverWait(browser, 10).until(lambda browser: glyph.is_displayed())
    WebDriverWait(browser, 10).until(lambda browser: not glyph.is_displayed()) 
開發者ID:jupyter,項目名稱:nbgrader,代碼行數:7,代碼來源:formgrade_utils.py

示例12: press_escape

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def press_escape(self) -> Element:
        return self.press(Keys.ESCAPE) 
開發者ID:yashaka,項目名稱:selene,代碼行數:4,代碼來源:entity.py

示例13: test_dbsv005_mouse_selection

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def test_dbsv005_mouse_selection(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(user_interactions_layout(
        dash_bio.SequenceViewer(
            id=_COMPONENT_ID,
            sequence=_data
        )
    ))

    user_interactions_callback(
        app,
        dash_duo,
        component_id=_COMPONENT_ID,
        prop_name='mouseSelection'
    )

    output_div = dash_duo.find_element('#interaction-results')

    sequence = dash_duo.find_element('.fastaSeq')

    ac = ActionChains(dash_duo.driver)
    ac.move_to_element(sequence)
    ac.move_by_offset(
        -(sequence.size['width']/2), -(sequence.size['height']/2)
    )
    ac.click_and_hold()
    ac.move_by_offset(85, 0)
    ac.release()
    ac.perform()

    expected_info = {
        'selection': 'MALWMRLLPL',
        'start': 1,
        'end': 10
    }

    assert output_div.get_attribute('innerHTML') == json.dumps(expected_info)

    # select something else

    ac = ActionChains(dash_duo.driver)
    ac.move_to_element(sequence)
    ac.move_by_offset(
        -(sequence.size['width']/2 - 100), -(sequence.size['height']/2 - 20)
    )
    ac.click_and_hold()
    ac.move_by_offset(55, 0)
    ac.release()
    ac.perform()

    expected_info = {
        'selection': 'PKTRREA',
        'start': 52,
        'end': 58
    }

    assert output_div.get_attribute('innerHTML') == json.dumps(expected_info)

    ac.send_keys(Keys.ESCAPE) 
開發者ID:plotly,項目名稱:dash-bio,代碼行數:63,代碼來源:test_sequence_viewer.py

示例14: delete_ad

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def delete_ad(driver, ad):
    log.info("\tDeleting ad ...")

    driver.get("https://www.ebay-kleinanzeigen.de/m-meine-anzeigen.html")
    fake_wait()

    ad_id_elem = None

    if "id" in ad:
        try:
            ad_id_elem = driver.find_element_by_xpath("//a[@data-adid='%s']" % ad["id"])
        except NoSuchElementException as e:
            log.info("\tNot found by ID")

    if ad_id_elem is None:
        try:
            ad_id_elem = driver.find_element_by_xpath("//a[contains(text(), '%s')]/../../../../.." % ad["title"])
        except NoSuchElementException as e:
            log.info("\tNot found by title")

    if ad_id_elem is not None:
        try:
            btn_del = ad_id_elem.find_element_by_class_name("managead-listitem-action-delete")
            btn_del.click()

            fake_wait()

            btn_confirm_del = driver.find_element_by_id("modal-bulk-delete-ad-sbmt")
            btn_confirm_del.click()

            log.info("\tAd deleted")
            fake_wait(randint(2000, 3000))
            webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
            return True

        except NoSuchElementException as e:
            log.info("\tDelete button not found")
    else:
        log.info("\tAd does not exist (anymore)")

    ad.pop("id", None)
    return False


# From: https://stackoverflow.com/questions/983354/how-do-i-make-python-to-wait-for-a-pressed-key 
開發者ID:donwayo,項目名稱:ebayKleinanzeigen,代碼行數:47,代碼來源:kleinanzeigen.py

示例15: test_show_hide_date_time_picker_widgets

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import ESCAPE [as 別名]
def test_show_hide_date_time_picker_widgets(self):
        """
        Pressing the ESC key or clicking on a widget value closes the date and
        time picker widgets.
        """
        from selenium.webdriver.common.keys import Keys

        self.admin_login(username='super', password='secret', login_url='/')
        # Open a page that has a date and time picker widgets
        self.selenium.get(self.live_server_url + reverse('admin:admin_widgets_member_add'))

        # First, with the date picker widget ---------------------------------
        cal_icon = self.selenium.find_element_by_id('calendarlink0')
        # The date picker is hidden
        self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
        # Click the calendar icon
        cal_icon.click()
        # The date picker is visible
        self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'block')
        # Press the ESC key
        self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])
        # The date picker is hidden again
        self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
        # Click the calendar icon, then on the 15th of current month
        cal_icon.click()
        self.selenium.find_element_by_xpath("//a[contains(text(), '15')]").click()
        self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
        self.assertEqual(
            self.selenium.find_element_by_id('id_birthdate_0').get_attribute('value'),
            datetime.today().strftime('%Y-%m-') + '15',
        )

        # Then, with the time picker widget ----------------------------------
        time_icon = self.selenium.find_element_by_id('clocklink0')
        # The time picker is hidden
        self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
        # Click the time icon
        time_icon.click()
        # The time picker is visible
        self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'block')
        self.assertEqual(
            [
                x.text for x in
                self.selenium.find_elements_by_xpath("//ul[@class='timelist']/li/a")
            ],
            ['Now', 'Midnight', '6 a.m.', 'Noon', '6 p.m.']
        )
        # Press the ESC key
        self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])
        # The time picker is hidden again
        self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
        # Click the time icon, then select the 'Noon' value
        time_icon.click()
        self.selenium.find_element_by_xpath("//a[contains(text(), 'Noon')]").click()
        self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
        self.assertEqual(
            self.selenium.find_element_by_id('id_birthdate_1').get_attribute('value'),
            '12:00:00',
        ) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:61,代碼來源:tests.py


注:本文中的selenium.webdriver.common.keys.Keys.ESCAPE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。