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


Python ActionChains.click方法代码示例

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


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

示例1: click_menu_option_by_visible_text

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def click_menu_option_by_visible_text(self, menu_locator,
                                          list_of_menu_options):
        """
        Performs a move_to_element action on every link <a...> contained in
        menu_locator if its visible text matches any of the names defined in
        list_of_menu_options and clicks on the last matching link.


        """
        menu_options = self.driver.find_elements(*menu_locator)
        actions = ActionChains(self.driver)
        menu_index = 0
        expected_option = None
        for option in menu_options:
            if menu_index >= len(list_of_menu_options):
                break
            if expected_option is None:
                expected_option = list_of_menu_options[menu_index].strip()

            if (option.get_attribute('title') == expected_option or
                    option.get_attribute('text') == expected_option or
                    option.text == expected_option):
                actions.move_to_element(option)
                menu_index += 1
                expected_option = None
        actions.click()
        actions.perform()
开发者ID:Chuwiey,项目名称:modules-activitysnippet,代码行数:29,代码来源:driver.py

示例2: testSelectingMultipleItems

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def testSelectingMultipleItems(self, driver, pages):
        """Copied from org.openqa.selenium.interactions.CombinedInputActionsTest."""
        if driver.capabilities['browserName'] == 'firefox':
            pytest.skip("Actions not available in Marionette. https://bugzilla.mozilla.org/show_bug.cgi?id=1292178")
        if driver.capabilities['browserName'] == 'phantomjs':
            pytest.xfail("phantomjs driver does not seem to select all the elements")

        pages.load("selectableItems.html")
        reportingElement = driver.find_element_by_id("infodiv")
        assert "no info" == reportingElement.text

        listItems = driver.find_elements_by_tag_name("li")
        selectThreeItems = ActionChains(driver) \
            .key_down(Keys.CONTROL) \
            .click(listItems[1]) \
            .click(listItems[3]) \
            .click(listItems[5]) \
            .key_up(Keys.CONTROL)
        selectThreeItems.perform()

        assert "#item2 #item4 #item6" == reportingElement.text

        # Now click on another element, make sure that's the only one selected.
        actionsBuilder = ActionChains(driver)
        actionsBuilder.click(listItems[6]).perform()
        assert "#item7" == reportingElement.text
开发者ID:glib-briia,项目名称:selenium,代码行数:28,代码来源:interactions_tests.py

示例3: goToMatsPerformQuery

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def goToMatsPerformQuery(self):
        # Try to find "Return to search page" link.
        t = g_bd.d.find_elements_by_link_text('Return')
        if len(t) > 0:
            self.focusActiveElement()
            t[0].click()
            time.sleep(g_param['waitMainMenu']/2)
            return

        # Otherwise, assume we are on the main menu and try to click on
        # MATS Perform Query image.
        else:
            imgs = g_bd.d.find_elements_by_tag_name('img')
            i=1
            for img in imgs:
                if (img.get_attribute('src').find(g_mats['imageLinkPerform'])\
                    >= 0
                    ):
                    test = ActionChains(g_bd.d)
                    test.move_to_element_with_offset(img, 158, 1)
                    test.click()
                    self.focusActiveElement()
                    test.perform()
                    # Give some time for the click to take effect.
                    time.sleep(g_param['waitMainMenu'])
                    return

            # If no appropriate image/link has been found, go back to eQ home
            # and try again.
            self.goToHome()
            return self.goToMatsPerformQuery()
开发者ID:b4stien,项目名称:slb,代码行数:33,代码来源:aeq_Boris.py

示例4: parse

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [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

示例5: search_brand

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
def search_brand(item, name):
    '''搜需要的品牌'''
    print 'in search_brand',item,name
    try:  # 如果找不到,就直接return
        lis = driver.find_elements_by_class_name(item)
    except:
        print platfm.local_str('没有' + item + '条目,返回')
        return
    print 'after find'
    # driver.set_page_load_timeout(0.5) #0.5s超时,太短的话(0.1s)click可能会超时
    driver.set_page_load_timeout(4)  # 等待嵌套页面加载需要的时间较长
    for li in lis:
        info = li.find_element_by_class_name(name).text
        print info
        # 至少包括Brands里的一项,包括Keys里的所有项
        if (filter(lambda x: x.lower() in info.lower(), Brands) and
                (Keys and Keys == filter(lambda x: x.lower() in info.lower(),
                 Keys) or not Keys)):
            global MixFlag
            if u"男女" in info:
                MixFlag = True
            action = ActionChains(driver)
            action.click(li).perform()
            print 'after click'
            time.sleep(5)
            print 'after sleep'
            # 切换到新的窗口
            print 'go into ' + info
            page.switch_do(driver, process)
            MixFlag = False
开发者ID:lostpaddle,项目名称:vipshop-buy,代码行数:32,代码来源:master.py

示例6: nest_page

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
def nest_page(driver):
    '''处理嵌套页面的情况:页面内又含有分支页面'''
    print 'in nest_page'
    global Depth
    if Depth <= 1:  # 深度最多为1层
        try:
            driver.find_element_by_class_name('pro_list_pic')
        except NoSuchElementException:
            Depth += 1
            print 'need to jump again'
            eles = driver.find_elements_by_tag_name('a')
            pattern = re.compile('show-\d+.html$')
            for ele in eles:
                if pattern.search(str(ele.get_attribute('href'))):
                    print 'before click'
                    action = ActionChains(driver)
                    action.click(ele).perform()
                    print 'after click'
                    # 切换到新的窗口
                    base_page = ele.get_attribute('href')
                    print 'go into ' + base_page
                    try:
                        driver.current_url
                    except:
                        pass
                    page.switch_do(driver, process, base_page)
            Depth -= 1
            return
开发者ID:lostpaddle,项目名称:vipshop-buy,代码行数:30,代码来源:master.py

示例7: mouse_move_to_random_one

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def mouse_move_to_random_one(self):
        try:
            searchResultsInColumn_ss = self.driver.find_elements_by_css_selector(ResultPageMap['searchResultAdContainerCss'])
            results_random_ss = random.choice(searchResultsInColumn_ss)
            global random_one_creativeid_ss
            random_one_creativeid_ss = results_random_ss.get_attribute("creativeid")
            print "The random selected one from the results list is %s." % random_one_creativeid_ss

            self.wait_for_element_visibility(5,
                                             "cssSelector",
                                             ".adcontainer[creativeid='" + random_one_creativeid_ss + "']"
            )
            random_one = self.find_element("cssSelector",
                                           ".adcontainer[creativeid='" + random_one_creativeid_ss + "']"
            )

            actions = ActionChains(self.driver)
            actions.move_to_element(random_one)
            print "actions - move mouse to element"
            actions.click(random_one)
            print "actions - click the element"
            actions.perform()
            print "actions - done"
        except:
            raise IncorrectPageException
开发者ID:ronnywang9,项目名称:Motivation,代码行数:27,代码来源:ResultPage.py

示例8: click

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
 def click(self):
     """
     Left-clicks the current cursor position
     """
     from selenium.webdriver.common.action_chains import ActionChains
     act = ActionChains(self.test)
     act.click().perform()
开发者ID:2gis,项目名称:mapsapi,代码行数:9,代码来源:page.py

示例9: add_to_shimo

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [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

示例10: test_vessel_track

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def test_vessel_track(self):
        driver = server.driver
        try:
            driver.set_window_size(1280, 776)
            driver.get("http://localhost:8000/index.html?workspace=/ui_tests/data/testtiles/workspace")
            time.sleep(5)

            self.setAnimation("ClusterAnimation")

            self.load_helpers()
            point = self.latLng2Point({'lat':22.5, 'lng':0.0})

            actions = ActionChains(driver)
            actions.move_to_element_with_offset(driver.find_element_by_xpath("//div[@class='animations']/div/div/div[2]"), point['x'], point['y'])
            actions.click()
            actions.perform()

            server.wait_for(lambda: self.animationHasLoaded("VesselTrackAnimation"))

            self.assertEqual(self.getHover(point, "ClusterAnimation"), 27200, "Seriesgroup not present at x,y")

        except:
            name = os.path.realpath("ui_tests.test.test_home.png")
            driver.get_screenshot_as_file(name)
            raise
开发者ID:liubobj,项目名称:pelagos-client,代码行数:27,代码来源:test.py

示例11: test_zoom

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def test_zoom(self):
        driver = server.driver
        try:
            driver.set_window_size(1280, 776)
            driver.get("http://localhost:8000/index.html?workspace=/ui_tests/data/testtiles/workspace")
            time.sleep(5)

            self.setAnimation("ClusterAnimation")

            def get_tiles():
                tiles = driver.execute_script("return Object.keys(visualization.data.sources['TiledBinFormat|/ui_tests/data/testtiles/.'].source.wantedTiles)")
                tiles.sort()
                return tiles

            server.wait_for(lambda: self.animationHasLoaded("ClusterAnimation"))
            
            self.assertEqual(get_tiles(), [u'-22.5,-11.25,0,0', u'-22.5,-22.5,0,-11.25', u'-22.5,-33.75,0,-22.5', u'-22.5,0,0,11.25', u'-22.5,11.25,0,22.5', u'-22.5,22.5,0,33.75', u'-45,-11.25,-22.5,0', u'-45,-22.5,-22.5,-11.25', u'-45,-33.75,-22.5,-22.5', u'-45,0,-22.5,11.25', u'-45,11.25,-22.5,22.5', u'-45,22.5,-22.5,33.75', u'-67.5,-11.25,-45,0', u'-67.5,-22.5,-45,-11.25', u'-67.5,-33.75,-45,-22.5', u'-67.5,0,-45,11.25', u'-67.5,11.25,-45,22.5', u'-67.5,22.5,-45,33.75', u'0,-11.25,22.5,0', u'0,-22.5,22.5,-11.25', u'0,-33.75,22.5,-22.5', u'0,0,22.5,11.25', u'0,11.25,22.5,22.5', u'0,22.5,22.5,33.75', u'22.5,-11.25,45,0', u'22.5,-22.5,45,-11.25', u'22.5,-33.75,45,-22.5', u'22.5,0,45,11.25', u'22.5,11.25,45,22.5', u'22.5,22.5,45,33.75', u'45,-11.25,67.5,0', u'45,-22.5,67.5,-11.25', u'45,-33.75,67.5,-22.5', u'45,0,67.5,11.25', u'45,11.25,67.5,22.5', u'45,22.5,67.5,33.75'])

            actions = ActionChains(driver)
            actions.click(driver.find_element_by_xpath('//div[@title="Zoom in"]'))
            actions.perform()

            time.sleep(1)
            server.wait_for(lambda: self.animationHasLoaded("ClusterAnimation"))

            self.assertEqual(get_tiles(), [u'-11.25,-11.25,0,-5.625', u'-11.25,-16.875,0,-11.25', u'-11.25,-5.625,0,0', u'-11.25,0,0,5.625', u'-11.25,11.25,0,16.875', u'-11.25,5.625,0,11.25', u'-22.5,-11.25,-11.25,-5.625', u'-22.5,-16.875,-11.25,-11.25', u'-22.5,-5.625,-11.25,0', u'-22.5,0,-11.25,5.625', u'-22.5,11.25,-11.25,16.875', u'-22.5,5.625,-11.25,11.25', u'-33.75,-11.25,-22.5,-5.625', u'-33.75,-16.875,-22.5,-11.25', u'-33.75,-5.625,-22.5,0', u'-33.75,0,-22.5,5.625', u'-33.75,11.25,-22.5,16.875', u'-33.75,5.625,-22.5,11.25', u'0,-11.25,11.25,-5.625', u'0,-16.875,11.25,-11.25', u'0,-5.625,11.25,0', u'0,0,11.25,5.625', u'0,11.25,11.25,16.875', u'0,5.625,11.25,11.25', u'11.25,-11.25,22.5,-5.625', u'11.25,-16.875,22.5,-11.25', u'11.25,-5.625,22.5,0', u'11.25,0,22.5,5.625', u'11.25,11.25,22.5,16.875', u'11.25,5.625,22.5,11.25', u'22.5,-11.25,33.75,-5.625', u'22.5,-16.875,33.75,-11.25', u'22.5,-5.625,33.75,0', u'22.5,0,33.75,5.625', u'22.5,11.25,33.75,16.875', u'22.5,5.625,33.75,11.25'])

        except:
            name = os.path.realpath("ui_tests.test.test_zoom.png")
            driver.get_screenshot_as_file(name)
            raise
开发者ID:liubobj,项目名称:pelagos-client,代码行数:33,代码来源:test.py

示例12: test_free_preicing_login_paid_pricing_in_dashboard_page

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
	def test_free_preicing_login_paid_pricing_in_dashboard_page(self):
		driver = self.driver
		CommonFun.siginInPm(driver, config["paid_pricing"]["H2_USERNAME"], config["paid_pricing"]["H2_PASSWORD"])

		driver.get(config["DASHBOARD_URL"])
		print "\n **** start test permission (paid_pricing account) ****"

		reminder = driver.find_element_by_class_name("reminder")
		ActionChains(driver).move_to_element(reminder).click().perform()
		CommonFun.closeClinicPaidAlert(driver, "reminder")
		reminder_clost_btn = driver.find_element(By.ID, "reminderCloseBtn")
		reminder_clost_btn.click()

		driver.find_element_by_id("navGroups").click()
		CommonFun.closeClinicPaidAlert(driver, "nav - groups")

		nav_admiinistration = driver.find_element_by_id("navAdministration")
		action = ActionChains(driver)
		action.move_to_element(nav_admiinistration)
		action.click()
		action.move_to_element(driver.find_element(By.ID, "menuBroadcast"))
		action.click()
		action.perform()
		CommonFun.closeClinicPaidAlert(driver, "nav - Administration - Broadcast")

		driver.find_element_by_id("navAlerts").click()
		CommonFun.closeClinicPaidAlert(driver, "nav - Alerts")
开发者ID:sunry81914,项目名称:starterLearns,代码行数:29,代码来源:test_pricing.py

示例13: testSelectingMultipleItems

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def testSelectingMultipleItems(self, driver, pages):
        """Copied from org.openqa.selenium.interactions.CombinedInputActionsTest."""
        pages.load("selectableItems.html")
        if driver.capabilities["browserName"] == "phantomjs":
            pytest.xfail("phantomjs driver does not seem to select all the elements")
        reportingElement = driver.find_element_by_id("infodiv")
        assert "no info" == reportingElement.text

        listItems = driver.find_elements_by_tag_name("li")
        selectThreeItems = (
            ActionChains(driver)
            .key_down(Keys.CONTROL)
            .click(listItems[1])
            .click(listItems[3])
            .click(listItems[5])
            .key_up(Keys.CONTROL)
        )
        selectThreeItems.perform()

        assert "#item2 #item4 #item6" == reportingElement.text

        # Now click on another element, make sure that's the only one selected.
        actionsBuilder = ActionChains(driver)
        actionsBuilder.click(listItems[6]).perform()
        assert "#item7" == reportingElement.text
开发者ID:zhjwpku,项目名称:selenium,代码行数:27,代码来源:interactions_tests.py

示例14: parse

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
    def parse(self, response):
        self.driver.get(response.url)

        while True:
            time.sleep(1)
            try:
                WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, '//p[@class="propertyName"]/a')))
            except TimeoutException:
                return
            resp = TextResponse(url=self.driver.current_url, body=self.driver.page_source, encoding='utf-8')
            urls = resp.xpath('//p[@class="propertyName"]/a/@href').extract()
            pprint(urls)
            #urls=['http://www.magicbricks.com/propertyDetails/270-Sq-ft-Studio-Apartment-FOR-Sale-Vatika-City-in-Gurgaon&id=4d423230333337333839?from=search']
            if len(urls) == 0:
                return
            for url in urls:
                abs_url = 'http://www.squareyards.com' + url
                yield scrapy.Request(abs_url, callback=self.parse_property_info)

            try :
                link = self.driver.find_element_by_xpath('//ul[@class="newpagination"]/li[2]')
                actions = ActionChains(self.driver)
                actions.click(link)
                actions.perform()
            except:
                return
开发者ID:JINDALG,项目名称:Roofpik_scrapy,代码行数:28,代码来源:sqyrd.py

示例15: parse

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click [as 别名]
	def parse(self, response):
		self.driver.get(response.url)
		try:
			WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, '//a[@class="list-name"]')))
		except TimeoutException:
			return
		resp = TextResponse(url=self.driver.current_url, body=self.driver.page_source, encoding='utf-8')
		urls = resp.xpath('//a[@class="list-name"]/@href').extract()
		old = 0
		new = len(urls)
		while old != new:
			print "\n\n\n",old,new,"\n\n\n"
			for i in xrange(old,new):
				abs_url = 'http://www.housing.com' + urls[i]
				yield scrapy.Request(abs_url, callback=self.parse_property_info)
			try :
				link = self.driver.find_element_by_xpath('//div[@class="show-more-container"]')
				actions = ActionChains(self.driver)
				actions.click(link)
				actions.perform()
			except:
				self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
			time.sleep(3)
			resp = TextResponse(url=self.driver.current_url, body=self.driver.page_source, encoding='utf-8')
			urls = resp.xpath('//a[@class="list-name"]/@href').extract()
			old = new
			new = len(urls)
开发者ID:JINDALG,项目名称:Roofpik_scrapy,代码行数:29,代码来源:housing.py


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