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


Python ActionChains.send_keys方法代码示例

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


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

示例1: modelWalker

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
def modelWalker():
    global driver, prevTrail, models
    act=ActionChains(driver)
    CSSs = driver.find_elements_by_css_selector
    try:
        startIdx = getStartIdx()
        for idx, model in enumerate(models[startIdx:],len(models)):
            ulog('idx=%s, model="%s"'%(idx,model))
            goToUrl(rootUrl)
            btn=waitClickable('.search-select button')
            act.move_to_element(btn).click(btn).perform()
            inp=waitClickable('.input-block-level')
            act.move_to_element(inp).click(inp).perform()
            act.send_keys(model + Keys.DOWN + Keys.ENTER).perform()
            time.sleep(0.1)
            waitUntil(isReadyState)
            ulog('url='+driver.current_url)
            title = waitText('.lightGrayBg > div > div > div > h2')
            ulog('title='+title) 
            # 'Search by Model Number' or 'No Matches Found'
            if title.startswith('No Matches Found'):
                continue
            prevTrail+=[idx]
            tabWalker()
            prevTrail.pop()
    except Exception as ex:
        ipdb.set_trace()
        traceback.print_exc()
开发者ID:MikimotoH,项目名称:Zyxel_Harvest,代码行数:30,代码来源:zyxel_harvest.py

示例2: visit_pages

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
def visit_pages(iteration, target_url):
	#search the next valid result
	while (iteration > 0):
		actions = ActionChains(driver);
		actions.send_keys(u'\ue015');
		actions.perform();
		actions.reset_actions();
		time.sleep(TIMEOUT_BROWSING_THROUGH_RESULTS);
		iteration = iteration-1;	
	actions = ActionChains(driver);
	actions.send_keys(u'\ue007');
	actions.perform();
	actions.reset_actions();
	time.sleep(WAITING_TIME_FOR_PAGE_LOAD);
	url = driver.current_url;	
	TIME_SPENT_ON_THE_PAGE = 0;
	parsed_url = url_parser( url );
	logfile.write(strftime("%Y-%m-%d %H:%M:%S  ", gmtime()) + "Visiting domain " + parsed_url + "\n");
	print(strftime("%Y-%m-%d %H:%M:%S  ", gmtime()) + "Visiting domain " + parsed_url + "\n");
	if parsed_url == target_url:
		TIME_SPENT_ON_THE_PAGE = 20;
		logfile.write(strftime("%Y-%m-%d %H:%M:%S  ", gmtime()) + "Target domain found\n");
		print(strftime("%Y-%m-%d %H:%M:%S  ", gmtime()) + "Target domain found\n");
		user_browses_internal_links(NUMBER_OF_INTERNAL_LINKS, TIME_SPENT_ON_A_LINK_WHILE_BROWSING, driver);
		user_browses_external_links(NUMBER_OF_EXTERNAL_LINKS, TIME_SPENT_ON_A_LINK_WHILE_BROWSING, driver);
	else:
		TIME_SPENT_ON_THE_PAGE = 1;
	time.sleep(TIME_SPENT_ON_THE_PAGE);
	driver.back();
	return;
开发者ID:mihai87,项目名称:WbSTls,代码行数:32,代码来源:autogs.py

示例3: test_permission_using_enter_key

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
    def test_permission_using_enter_key(self):
        """
        Try to add/delete persmission using enter key
        """
        # try to add using enter key
        self.init_app()
        self.add_record(data_selfservice.ENTITY,
                        data_selfservice.DATA1,
                        dialog_btn=None)
        actions = ActionChains(self.driver)
        actions.send_keys(Keys.ENTER).perform()
        self.wait()
        self.assert_notification(assert_text=SERVICE_ADDED)
        self.assert_record(data_selfservice.DATA1['pkey'])
        self.close_notifications()

        # try to delete using enter key
        self.navigate_to_entity(data_selfservice.ENTITY)
        self.select_record(data_selfservice.DATA1['pkey'])
        self.facet_button_click('remove')
        actions = ActionChains(self.driver)
        actions.send_keys(Keys.ENTER).perform()
        self.wait()
        self.assert_notification(assert_text='1 item(s) deleted')
        self.close_notifications()
开发者ID:encukou,项目名称:freeipa,代码行数:27,代码来源:test_selfservice.py

示例4: test_06_link_in_new_window

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
    def test_06_link_in_new_window(self):

        driver = self.driver

        try:
            elm_catering_charges = driver.find_element_by_link_text("Catering Charges")
            action_chain = ActionChains(driver)

            # open link in a new window
            action_chain.send_keys(Keys.SHIFT).click(elm_catering_charges).send_keys(Keys.SHIFT).perform()
            sleep(2)
            print driver.current_window_handle
            window_handles = driver.window_handles
            driver.switch_to.window(window_handles[-1])
            print driver.current_window_handle
            driver.close()
            driver.switch_to.window(window_handles[0])


        except EX.StaleElementReferenceException:
            print self._testMethodName + " - Error at line number : " + sys.exc_traceback.tb_lineno
            print sys.exc_info()
        except NoSuchElementException:
            print self._testMethodName + " - Error at line number : " + sys.exc_traceback.tb_lineno
            print sys.exc_info()
开发者ID:biswajit-713,项目名称:STAF,代码行数:27,代码来源:IR_Train_Search.py

示例5: add_to_shimo

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
def add_to_shimo(content):
	driver = webdriver.Chrome(sys.argv[1])  # Optional argument, if not specified will search path.
	#driver.add_cookie({'name' : 'session', 'value' : 'eyJfaWQiOnsiIGIiOiJaalUyTm1aak5EVTRPRE5qWWpVNU9HWmtNalZoWmpBNE4yUTNaR016TkRrPSJ9fQ', 'path' : '/'})
	driver.implicitly_wait(0)
	driver.get('https://www.shimo.im/')
	cookies = pickle.load(open("cookies.pkl", "rb"))
	for cookie in cookies:
		driver.add_cookie(cookie)
	driver.get('https://www.shimo.im/doc/g8XvnVEvCtEWnvrB')
	try:
		search_box = driver.find_element_by_class_name('locate')
		mouse = ActionChains(driver)
		mouse.move_to_element_with_offset(search_box, 0, 0)
		mouse.click()
		mouse.send_keys(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ': %s\n' % content)
		mouse.perform()
	except:
		mouse = ActionChains(driver)
		mouse.move_by_offset(290, 400)
		mouse.click()
		mouse.send_keys(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ': %s\n' % content)
		mouse.perform()
		
	time.sleep(5)
	driver.quit()
开发者ID:qipa-debate,项目名称:qipa-debate-server,代码行数:27,代码来源:transmitter.py

示例6: init_browser

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
    def init_browser(self):
        if True:# self.browser_type == "firefox".upper():
                # adding adblock to the system
                
                #binary = FirefoxBinary(r"Drivers/firefox/bin/firefox.exe")
#                firefox_profile = FirefoxProfile()
#                if self.adblock is True:
#                    adblock_path = os.path.abspath('Drivers/adblock_plus-2.7.3-sm+tb+fx+an.xpi')
#                    firefox_profile.add_extension(extension=adblock_path)

                binary = FirefoxBinary(self.browser_path)
                self.browser = Firefox(firefox_binary=binary)
                
                # muting the browser
                action = ActionChains(self.browser)
                action.send_keys(Keys.CONTROL + "m")
                action.perform()                
                
        elif self.browser_type == "Edge".upper():
            edge_driver = "Drivers/EdgeDriver"
            os.environ["webdriver.edge.driver"] = edge_driver
            self.browser = Edge(edge_driver)   
        elif self.browser_type == "PHANTOMJS":
            user_agent = (
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) " +
                "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"
            )
            dcap = dict(DesiredCapabilities.PHANTOMJS)
            dcap["phantomjs.page.settings.userAgent"] = user_agent
            self.browser = PhantomJS("Drivers/phantomjs.exe", desired_capabilities=dcap)
开发者ID:TheBlueFireFox,项目名称:KissExtractor,代码行数:32,代码来源:extractor.py

示例7: test_p_after_p

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
def test_p_after_p():
    # Ensure that hitting "Enter" after a p successfully creates a following p
    # tag
    d = _get_driver()

    # Open the basic example page
    d.get('%s/basic.html' % BASE_TEST_URL)
    assert d.title == 'WYMeditor'

    # Move the selection to the end of the first paragraph
    _switch_to_editor_content(d)
    body = _get_editor_body(d)
    body.click()  # Put the cursor focus in the body
    chain = ActionChains(d)
    chain.send_keys(Keys.RIGHT * 20)
    chain.perform()

    # Hit return to create a new paragraph
    chain.send_keys(Keys.RETURN)
    chain.perform()

    assert body.get_attribute("innerHTML") == (
            '<p>This is some text with which to test.</p>'
            '<p><br></p>')

    d.close()
开发者ID:CharString,项目名称:wymeditor,代码行数:28,代码来源:test_root_containers.py

示例8: busca_americanas

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
def busca_americanas(url_item):
    driver.get(url_item)
    
    stop_loading_action = ActionChains(driver)
    stop_loading_action.send_keys(Keys.ESCAPE)
    stop_loading_action.perform()
    
    #driver.send_keys(Keys.ESCAPE)
    
    if constants.AMERICANAS_ESGOTADO in driver.page_source:
        #print('Produto esgotado nas Americanas.')
        output('Produto esgotado nas Americanas.')
    else:
        elem_preco = WebDriverWait(driver, constants.SECONDS_OF_WAIT).until(
            expected_conditions.presence_of_element_located(\
                (By.XPATH, constants.AMERICANAS_PRECO)
            )
        )        

        elem_parcelas = WebDriverWait(driver, constants.SECONDS_OF_WAIT).until(
            expected_conditions.presence_of_element_located(\
                (By.XPATH, constants.AMERICANAS_PARCELAS)
            )
        )
        #print('Produto não esgotado nas Americanas.')
        list_output = []
        list_output.append('Preço: ')
        list_output.append(elem_preco.text)
        list_output.append(' em ')
        list_output.append(elem_parcelas.text)
        output(''.join(list_output))    
开发者ID:gabrielbf,项目名称:Jarvis,代码行数:33,代码来源:jarvis.py

示例9: testCreateRide

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
    def testCreateRide(self):
        self.driver.get('http://localhost:8002/')
        WebDriverWait(self.driver, 10).until(lambda s: s.find_element_by_id("login_email").is_displayed())
        actions = ActionChains(self.driver)
        login_email = self.driver.find_element_by_id("login_email")
        actions.move_to_element(login_email).click()
        actions.send_keys("[email protected]")
        login_password = self.driver.find_element_by_id("login_password")
        actions.move_to_element(login_password).click()
        actions.send_keys("1").perform()
        # submit the form
        self.driver.find_element_by_id("login-btn").click()
        self.driver.find_element_by_link_text("Create a New Ride").click()

        actions = ActionChains(self.driver)
        open_seats = self.driver.find_element_by_id("open_seats")
        actions.move_to_element(open_seats).click()
        actions.send_keys("1")
        departure_time = self.driver.find_element_by_id("departure_time")
        actions.move_to_element(departure_time).click()
        actions.send_keys(Keys.ARROW_LEFT).send_keys(Keys.ARROW_LEFT).send_keys(Keys.ARROW_LEFT)
        self.driver.implicitly_wait(10)
        actions.send_keys("11112011\t1111AM").send_keys(Keys.ARROW_LEFT).perform()
        self.driver.find_element_by_id("create_ride_btn").click()
        self.assertEquals('Rideshare - Ride Detail', self.driver.title)
开发者ID:WenTingZhu,项目名称:isa-marketplace,代码行数:27,代码来源:tests.py

示例10: test_account_creation

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
    def test_account_creation(self):
        sel = self.selenium

        self.get_home()
        sel.find_element_by_link_text('log in or sign up').click()

        # Focus on the create account form email field
        sel.find_element_by_css_selector('#register-form input[name=email]').click()

        # Enter the email address
        email = '[email protected]'
        create = ActionChains(sel)
        create.send_keys(email)
        create.send_keys(Keys.RETURN)
        create.perform()

        # Check that we're now logged in
        self.assertLoggedInAs(email)

        # Check that we were send an email with a password in
        self.assertEqual(len(mail.outbox), 1)
        password = re.search(r'password: (\S+)', mail.outbox[0].body).group(1)
        self.assertTrue(password)

        # Check that the login link is correct
        login_link = re.search(r'(\S+/accounts/login/)', mail.outbox[0].body).group(1)
        self.assertEqual(login_link, settings.BASE_URL + "/accounts/login/")

        # Log out and check that we can log in with the new password
        self.logout()
        self.login(email, password)
开发者ID:OmniRose,项目名称:omnirose-website,代码行数:33,代码来源:tests.py

示例11: _Apply

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
  def _Apply(self, driver, test):
    expected_value = test.profile_data(self._expected_type)
    if expected_value != '':
      if self._trigger_character is None:
        trigger_character = expected_value[0]
      else:
        trigger_character = self._trigger_character
    else:
      test.expect_expression(
          overall_type,
          'Failure: Cannot trigger autofill, field_type \'%s\' '
          'does not have an expected value' % self._expected_type)
      return

    locator = self._element_selector.tuple()
    wt = WebDriverWait(driver, 15)  # seconds
    element = wt.until(EC.presence_of_element_located(locator))
    ActionChains(driver).move_to_element(element).perform()
    wt = WebDriverWait(driver, 10)  # seconds
    element = wt.until(EC.element_to_be_clickable(locator))
    ActionChains(driver).click(element).perform()
    time.sleep(1)
    actions = ActionChains(driver)
    actions.send_keys(trigger_character)
    actions.perform()
    time.sleep(0.5)
    actions = ActionChains(driver)
    actions.key_down(Keys.ARROW_DOWN)
    actions.key_down(Keys.ENTER)
    actions.perform()
    time.sleep(1)

    return True
开发者ID:Samsung,项目名称:ChromiumGStreamerBackend,代码行数:35,代码来源:actions.py

示例12: parse

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
	def parse(self,response):
		self.driver.get(response.url)
		self.driver.find_element_by_xpath('//div[@class="ui-state-default icon-div jQButtonNoWidth"]').click()
		time.sleep(1)
		targets = self.driver.find_elements_by_xpath('//a[@class="actionLink "]')
		scrollNum = len(self.driver.find_elements_by_xpath('//tr[@class="odd"]')[0].find_elements_by_xpath('.//td'))
		count = 0
		for target in targets:
			target.click()
			time.sleep(1)
			show = target.text
			date = self.driver.find_element_by_xpath('//div[@class="show-date"]').text
			scrollbar = self.driver.find_element_by_xpath('//div[@class="touchcarousel-wrapper auto-cursor"]')
			action = ActionChains(self.driver)
			action.move_to_element(scrollbar)
			action.click()
			for i in range(1,4):
				action.send_keys(Keys.ARROW_RIGHT)
			action.perform()
			time.sleep(1)
			count = count + 1
			links = self.driver.find_elements_by_xpath('//a[@class="product-description"]')
			for link in links:
				url = link.get_attribute("href")
				request = scrapy.Request(response.urljoin(url), self.parse_product)
				request.meta['day'] = date
				request.meta['show'] = show
				print len(targets)
				yield request
开发者ID:graysomb,项目名称:Scrapetastic,代码行数:31,代码来源:EVINE.py

示例13: test_disable_delete_admin

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
    def test_disable_delete_admin(self):
        """
        Test disabling/deleting admin is not allowed
        """
        self.init_app()
        self.navigate_to_entity(user.ENTITY)

        # try to disable admin user
        self.select_record('admin')
        self.facet_button_click('disable')
        self.dialog_button_click('ok')
        self.assert_last_error_dialog(ERR_ADMIN_DEL, details=True)
        self.dialog_button_click('ok')
        self.assert_record('admin')

        # try to delete admin user. Later we are
        # confirming by keyboard to test also ticket 4097
        self.select_record('admin')
        self.facet_button_click('remove')
        self.dialog_button_click('ok')
        self.assert_last_error_dialog(ERR_ADMIN_DEL, details=True)
        actions = ActionChains(self.driver)
        actions.send_keys(Keys.TAB)
        actions.send_keys(Keys.ENTER).perform()
        self.wait(0.5)
        self.assert_record('admin')
开发者ID:stlaz,项目名称:freeipa,代码行数:28,代码来源:test_user.py

示例14: testRegister

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
    def testRegister(self):
        browser.get(url)   
        browser.implicitly_wait(30)
        # browser.find_element_by_link_text('ÉîÛÚ').click()
        #µã»÷×¢²á
        browser.find_element_by_link_text(u'×¢²á').click()

        #µã»÷¸öÈË×¢²á
        browser.find_element_by_xpath('/html/body/div[2]/div[3]/div/div[2]/div/div/input').click()
        browser.switch_to_frame('personIframe')
        user=browser.find_element_by_xpath('/html/body/div/div/form/div/dl/dd/div/input')
        
        user.send_keys('sdfdsfs')
        email=browser.find_element_by_xpath('/html/body/div/div/form/div/dl[2]/dd/div/input')
        email.send_keys('[email protected]')
        password=browser.find_element_by_xpath('/html/body/div/div/form/div/dl[3]/dd/div/input[5]')
        password.send_keys('123456789a')
        reg=browser.find_element_by_xpath('/html/body/div/div/form/div/div[2]/input')


        action=ActionChains(browser)
        action.move_to_element(reg).perform()
        action.send_keys(Keys.ENTER).perform()
        time.sleep(10)
        if browser.current_url != 'http://shenzhen.dld.com/':
            browser.get_screenshot_as_file('regErr.png')
            self.fail('-×¢²áʧ°Ü|regErr.png-')
开发者ID:llych,项目名称:python,代码行数:29,代码来源:testDld.py

示例15: input_information

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import send_keys [as 别名]
def input_information(positives):
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get('http://vradhome/Privileging/Facility?facility')
    time.sleep(2)
    for k in range(len(positives)):
        fac_search = driver.find_element_by_id('s2id_autogen1')
        actions = ActionChains(driver)
        actions.move_to_element(fac_search)
        actions.click()
        actions.send_keys(positives[k][2]).perform()
        time.sleep(2)
        actions = ActionChains(driver)
        actions.send_keys(Keys.RETURN).perform()
        driver.implicitly_wait(10)
        ex_test = driver.find_elements_by_class_name("expand")
        # maybe avoide C2
        if len(ex_test) < 3:
            continue
        else:
            try:
                driver.implicitly_wait(20)
                name_spot = driver.find_element_by_xpath(
                    "//*[contains(text(), '{0}')]".format(positives[k][1]))
                driver.execute_script("return arguments[0].scrollIntoView();",name_spot)
                actions = ActionChains(driver)
                actions.move_to_element(name_spot).click().perform()
                expand = driver.find_elements_by_class_name("expand")[2]
                driver.execute_script("return arguments[0].scrollIntoView();",expand)
                expand.click()
                tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).strftime('%m/%d/%y')
                next_act = driver.find_elements_by_class_name("form-control")[0]
                comment = driver.find_elements_by_class_name("form-control")[9]
                actions = ActionChains(driver)
                actions.move_to_element(next_act).click()
                actions.send_keys('{0}'.format(tomorrow))
                actions.send_keys(Keys.TAB).perform()
                actions = ActionChains(driver)
                actions.send_keys("See Note (Rad Leaving)").perform()
                actions = ActionChains(driver)
                actions.move_to_element(comment).click().send_keys(
                    'Rad last read date on: {0}. Please stop app'
                    ' process and update status to WD. Please contact'
                    ' Roberta with questions.'.format(positives[k][0])
                    ).perform()
                
                driver.find_element_by_xpath('//*[@title="Submit Mass Update"]').click()
                time.sleep(7)
                print('{0} : {1} \nRad last read date on: {2}.\n'.format(
                      positives[k][1],positives[k][2],positives[k][0]))
                
            except selenium.common.exceptions.NoSuchElementException:
                    print("** Unable to find {0} at {1} **\n".format(positives[k][1].encode('ascii','ignore')
                                                                     ,positives[k][2].encode('ascii','ignore')))
            continue
          
        
        time.sleep(3)
    driver.quit()
开发者ID:jgscherber,项目名称:Virtual-Radiologic,代码行数:61,代码来源:leavingrad_classes.py


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