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


Python ActionChains.send_keys方法代码示例

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


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

示例1: test_student_find_the_cc_book_from_an_online_search_7742

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
    def test_student_find_the_cc_book_from_an_online_search_7742(self):
        """Find the Concept Coach book from an online search.

        Steps:
        Search the title of the book, with 'openstax' through a search engine

        Expected Result:
        The search returns a link to the book
        """
        self.ps.test_updates['name'] = 'cc1.12.003' \
            + inspect.currentframe().f_code.co_name[4:]
        self.ps.test_updates['tags'] = ['cc1', 'cc1.12', 'cc1.12.003', '7742']
        self.ps.test_updates['passed'] = False

        # Test steps and verification assertions
        self.student.driver.get('https://www.google.com')
        self.student.page.wait_for_page_load()
        actions = ActionChains(self.student.driver)
        actions.send_keys('openstax concept coach biology')
        actions.send_keys(Keys.RETURN)
        actions.perform()
        self.student.wait.until(
            expect.visibility_of_element_located(
                (By.XPATH,
                 '//a[contains(text(),"Biology with Concept Coach")]')
            )
        )
        self.student.driver.find_element(
            By.XPATH, '//cite[contains(text(),"https://cnx.org/")]')

        self.ps.test_updates['passed'] = True
开发者ID:openstax,项目名称:test-automation,代码行数:33,代码来源:test_cc1_12_DeliveringAssignments.py

示例2: find_text

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
 def find_text(self, text):
     #click the 'find' button, and enter text. Not yet functional
     self('editor_find_button').click()
     alert = self.browser.switch_to_alert()
     chain = ActionChains(alert)
     chain.send_keys(text).perform()
     chain.send_keys(Keys.RETURN).perform()
     return
开发者ID:Kenneth-T-Moore,项目名称:OpenMDAO-Framework,代码行数:10,代码来源:editor.py

示例3: test_report

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
    def test_report(self):
        self.browser.get(self.live_server_url + '/')

        # Login
        username = self.browser.find_element_by_id('username')
        username.send_keys('Jim')
        password = self.browser.find_element_by_id('password')
        # Send the wrong password
        password.send_keys('correcthorsebatterystaple')

        # Submit the form
        submit = self.browser.find_element_by_id('submit')
        submit.click()

        # Navigate to the sale page
        img = self.browser.find_element_by_xpath(
            '//div[@class="card small grey darken-3"][1]//img[@id="report-image"]')
        img.click()

        # Get the choose showing modal
        showing = self.browser.find_element_by_xpath(
            '//div[@class="col s6 center-align"][1]/button')
        showing.click()

        wait = WebDriverWait(self.browser, 10)
        element = wait.until(EC.element_to_be_clickable((By.ID, 'picker-modal')))

        modal = self.browser.find_element_by_id('picker-modal')
        self.assertTrue(modal.is_displayed())

        occ = self.browser.find_element_by_id('showing')
        occ.click()

        free_text = self.browser.find_element_by_xpath('//div[@id="sale-update"]//p').text
        self.assertIn('No tickets sold', free_text)
        self.assertIn('No tickets reserved', free_text)
        self.assertIn('80 tickets left', free_text)

        # Check selling tickets adds up properly
        pricing = models.InHousePricing.objects.get(id=1)
        member_price = pricing.member_price
        concession_price = pricing.concession_price
        public_price = pricing.public_price
        mat_f_price = pricing.matinee_freshers_price
        mat_f_nnt_price = pricing.matinee_freshers_nnt_price

        out = self.browser.find_element_by_id('out1').text

        member = self.browser.find_element_by_id('member')
        action = ActionChains(self.browser)
        action.click(on_element=member)
        action.send_keys('1')
        action.key_down(Keys.CONTROL)
        action.key_up(Keys.CONTROL)
        action.perform()
开发者ID:newtheatre,项目名称:nt-tickets,代码行数:57,代码来源:test_functional.py

示例4: rule_value

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
def rule_value(context, value):
    value_input = context.browser.find_element_by_xpath("//paper-input[@id='metricValue']")
    actions = ActionChains(context.browser)
    actions.move_to_element(value_input)
    actions.click()
    actions.send_keys(Keys.BACK_SPACE)
    actions.perform()

    actions.move_to_element(value_input)
    actions.click()
    actions.send_keys("0")
    actions.perform()
开发者ID:mistio,项目名称:mist.tests,代码行数:14,代码来源:mayday.py

示例5: create

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
    def create(self, tr):
        self.tds = tr.find_elements_by_tag_name('td')

        actions = ActionChains(self.driver)
        actions.move_to_element(self.tds[1])
        actions.double_click()
        actions.send_keys(lorem_ipsum.words(1, False))
        actions.perform()

        actions.move_to_element(self.tds[2])
        actions.double_click()
        actions.perform()

        self.driver.select('select.htSelectEditor', unicode(self.experiment.pk))
        self.driver.click('body')
开发者ID:labrepo,项目名称:LabRepo,代码行数:17,代码来源:seltests.py

示例6: test_remove_success

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
    def test_remove_success(self):
        table = self.driver.find_element_by_id('dataTable')
        self.create_units(table)

        tr = table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(3) + ')')
        actions = ActionChains(self.driver)
        actions.move_to_element(tr.find_element_by_css_selector('td:nth-child(2)'))
        actions.click()
        actions.key_down(Keys.SHIFT)
        actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(5) + ') td:nth-child(3)'))
        actions.click()
        actions.key_up(Keys.SHIFT)
        actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(4) + ') td:nth-child(3)'))
        actions.context_click().send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN)
        actions.send_keys(Keys.RETURN)
        actions.perform()
        self.assertEqual(len(self.driver.find_elements_by_css_selector('.htCore tbody tr')), 3 * 2)
开发者ID:labrepo,项目名称:LabRepo,代码行数:19,代码来源:seltests.py

示例7: key_appears

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
def key_appears(context, key, seconds):
    if context.mist_config.get(key):
        key_name = context.mist_config.get(key)
    timeout = time() + int(seconds)
    while time() < timeout:
        try:
            for key_in_list in context.browser.find_elements_by_class_name('small-list-item'):
                if key_name == safe_get_element_text(key_in_list):
                    actions = ActionChains(context.browser)
                    actions.send_keys(Keys.ESCAPE)
                    actions.perform()
                    return True
                else:
                    pass
        except:
            sleep(1)
    assert False, "Key %s did not appear after %s seconds" % (key,seconds)
开发者ID:mistio,项目名称:mist.tests,代码行数:19,代码来源:machines.py

示例8: web_actions

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
def web_actions(webdriver):
	try:
		actionChains = ActionChains(webdriver)
		actionChains.send_keys(keys.Keys.ARROW_DOWN).perform()
		time.sleep(1)
		x = 0
		t = 0
		while t < 6:
			t += 1
			if x == 0:
				webdriver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
				time.sleep(1)
				x += 1
			else:
				webdriver.execute_script("window.scrollTo(document.body.scrollHeight, 0);")
				time.sleep(1)
				x -= 1
	finally:
		print "finished!"
开发者ID:66eli77,项目名称:Ka-lite-front-end-benchmark-suite,代码行数:21,代码来源:user_defined_behaviors.py

示例9: trigger_keystrokes

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
def trigger_keystrokes(browser, *keys):
    """ Send the keys in sequence to the browser.
    Handles following key combinations
    1. with modifiers eg. 'control-alt-a', 'shift-c'
    2. just modifiers eg. 'alt', 'esc'
    3. non-modifiers eg. 'abc'
    Modifiers : http://seleniumhq.github.io/selenium/docs/api/py/webdriver/selenium.webdriver.common.keys.html
    """
    for each_key_combination in keys:
        keys = each_key_combination.split('-')
        if len(keys) > 1:  # key has modifiers eg. control, alt, shift
            modifiers_keys = [getattr(Keys, x.upper()) for x in keys[:-1]]
            ac = ActionChains(browser)
            for i in modifiers_keys: ac = ac.key_down(i)
            ac.send_keys(keys[-1])
            for i in modifiers_keys[::-1]: ac = ac.key_up(i)
            ac.perform()
        else:              # single key stroke. Check if modifier eg. "up"
            browser.send_keys(getattr(Keys, keys[0].upper(), keys[0]))
开发者ID:ian-r-rose,项目名称:notebook,代码行数:21,代码来源:utils.py

示例10: ScrollDown

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
 def ScrollDown(self, steps):
     assert steps >= 0
     ac = ActionChains(self.browser)
     for _ in range(steps):
         ac = ac.send_keys("j")
     while True:
         try:
             ac.perform()
             break
         except UnexpectedAlertPresentException:
             sleep(5)
开发者ID:inker610566,项目名称:FBCrawler,代码行数:13,代码来源:fbcontroller.py

示例11: test_remove_permission

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
 def test_remove_permission(self):
     table = self.driver.find_element_by_id('dataTable')
     self.create_units(table)
     self.driver.authorize(username=self.guest.email, password='qwerty')
     self.driver.open_url(reverse('units:list', kwargs={'lab_pk': unicode(self.lab.pk)}))
     table = self.driver.find_element_by_id('dataTable')
     tr = table.find_element_by_css_selector('.htCore tbody tr:nth-child(1)')
     actions = ActionChains(self.driver)
     actions.move_to_element(tr.find_element_by_css_selector('td:nth-child(2)'))
     actions.click()
     actions.key_down(Keys.SHIFT)
     actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(5) + ') td:nth-child(3)'))
     actions.click()
     actions.key_up(Keys.SHIFT)
     actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(4) + ') td:nth-child(3)'))
     actions.context_click().send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN)
     actions.send_keys(Keys.RETURN)
     actions.perform()
     self.assertTrue(self.driver.is_element_present('.alert-danger'))
     self.assertEqual(self.driver.find_element_by_css_selector('.messages').text, 'PERMISSION DENIED')
开发者ID:labrepo,项目名称:LabRepo,代码行数:22,代码来源:seltests.py

示例12: visit

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
  def visit( self, url ):
    '''
    '''

    if self.__jscoverage_loaded:

      self.__browser.switch_to_window( self.__browser.window_handles[0] )

    else:

      # load JSCoverage
      self.__browser.get( "http://localhost:8080/jscoverage.html" )
      self.__jscoverage_loaded = True


    # clear the jscoverage location field
    locationfield = self.__browser.find_element_by_id( 'location' )
    locationfield.clear()

    # fill in url
    actions = ActionChains( self.__browser )
    actions.click( locationfield )
    actions.send_keys( url )
    actions.send_keys( Keys.TAB )
    actions.send_keys( Keys.TAB )
    actions.send_keys( Keys.RETURN )
    actions.perform()

    # switch to the new window
    self.__browser.switch_to_window( self.__browser.window_handles[-1] )
开发者ID:151706061,项目名称:X,代码行数:32,代码来源:_tester.py

示例13: step_impl

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
def step_impl(context):
    passw=open('C:\\Projects\\first_behave\\python_behave_template-master\\pass.txt','r')
    actions = ActionChains(context.browser)
    actions.send_keys("vlad")
    actions.send_keys(Keys.TAB)
    actions.send_keys(passw.readline())
    actions.send_keys(Keys.ENTER)
    actions.perform()

    try:
        element = WebDriverWait(context.browser, 1).until(EC.presence_of_element_located((By.CSS_SELECTOR, "body > div.ng-scope > div.page.page--with-masthead.ng-scope > div > nav > ul:nth-child(1) > li:nth-child(2) > a > div > span"))
    )
        element.click()
        time.sleep(2)
    except Exception:
        print('error')
开发者ID:vladalexa,项目名称:tictrac_qa,代码行数:18,代码来源:first_behave.py

示例14: fill_codemirror_area_with

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
    def fill_codemirror_area_with(self, field_content):
        def find_codemirror(driver):
            try:
                driver.switch_to.default_content()
                driver.switch_to_frame(
                    driver.find_element_by_tag_name("iframe"))
                element = driver.find_element_by_xpath(
                    "//pre[contains(@class,'CodeMirror-line')]/../../../"
                    "*[contains(@class,'CodeMirror-code')]")
                if element.is_displayed() and element.is_enabled():
                    return element
            except (NoSuchElementException, WebDriverException):
                return False

        time.sleep(1)
        WebDriverWait(self.driver, timeout=self.timeout, poll_frequency=0.01).\
            until(find_codemirror, "Timed out waiting for codemirror "
                                   "to appear").click()
        time.sleep(1)

        action = ActionChains(self.driver)
        action.send_keys(field_content)
        action.perform()
开发者ID:thaJeztah,项目名称:pgadmin4,代码行数:25,代码来源:pgadmin_page.py

示例15: collab_create

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import send_keys [as 别名]
    def collab_create(self, collab_name):
        """Create new collab.
        """

        # Click the "Create" Header
        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, "//button[@class='md-tab-header']"))).click()
        time.sleep(4)

        # Select that CRAZY 'Create new collab' field ...
        elem = self._wait(By.XPATH, "//input[@placeholder='Create new collab']")
        elem.clear()
        actions = ActionChains(self.driver)
        actions.move_to_element(elem)
        actions.send_keys(collab_name)
        actions.perform()

        time.sleep(2)
        self.click(
            By.XPATH,
            "//button[@class='md-button md-raised md-primary "
            "button-medium separated md-theme-default']")
开发者ID:alex4200,项目名称:hello-world,代码行数:25,代码来源:hbpdriver.py


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