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


Python ActionChains.perform方法代码示例

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


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

示例1: and_perform_the_following_group1_query

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
def and_perform_the_following_group1_query(step, query_string):
    search_field = world.driver.find_element_by_css_selector('[class=ace_content]')
    time.sleep(1)
    seq = ActionChains(world.driver).move_to_element(search_field).send_keys(query_string)
    seq.perform()

    world.driver.find_element_by_css_selector('[data-type=run-query]').click()
开发者ID:manuelvelez,项目名称:preliminary-testing,代码行数:9,代码来源:steps.py

示例2: mouse_over

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
 def mouse_over(self):
     LOG.debug('Mouse over element %s' % str(self.locator))
     self.scroll_into_view()
     element = self.get_element()
     chain = ActionChains(self.driver)
     chain.move_to_element(element)
     chain.perform()
开发者ID:Scalr,项目名称:revizor-tests,代码行数:9,代码来源:base.py

示例3: test_copy_from_language

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
    def test_copy_from_language(self):
        self._login()
        self.driver.get('%s/it/?%s' % (self.live_server_url, get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON')))

        # check if there are no plugins in italian version of the page

        italian_plugins = self.page.placeholders.all()[0].get_plugins_list('it')
        self.assertEqual(len(italian_plugins), 0)

        build_button = self.driver.find_element_by_css_selector('.cms-toolbar-item-cms-mode-switcher a[href="?%s"]' % get_cms_setting('CMS_TOOLBAR_URL__BUILD'))
        build_button.click()

        submenu = self.driver.find_element_by_css_selector('.cms-dragbar .cms-submenu')

        hov = ActionChains(self.driver).move_to_element(submenu)
        hov.perform()

        submenu_link_selector = '.cms-submenu-item a[data-rel="copy-lang"][data-language="en"]'
        WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, submenu_link_selector)))
        copy_from_english = self.driver.find_element_by_css_selector(submenu_link_selector)
        copy_from_english.click()

        # Done, check if the text plugin was copied and it is only one

        WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.cms-draggable:nth-child(1)')))

        italian_plugins = self.page.placeholders.all()[0].get_plugins_list('it')
        self.assertEqual(len(italian_plugins), 1)

        plugin_instance = italian_plugins[0].get_plugin_instance()[0]

        self.assertEqual(plugin_instance.body, 'test')
开发者ID:philippze,项目名称:django-cms,代码行数:34,代码来源:test_frontend.py

示例4: edit_environment

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
    def edit_environment(self, old_name, new_name):
        el_td = self.driver.find_element_by_css_selector(
            'tr[data-display="{0}"] '.format(old_name) +
            'td[data-cell-name="name"]')
        el_pencil = el_td.find_element_by_css_selector(
            'button.ajax-inline-edit')

        # hover to make pencil visible
        hover = ActionChains(self.driver).move_to_element(el_td)
        hover.perform()
        el_pencil.click()

        # fill in inline input
        el_inline_input = self.driver.find_element_by_css_selector(
            'tr[data-display="{0}"] '.format(old_name) +
            'td[data-cell-name="name"] .inline-edit-form input')
        el_inline_input.clear()
        el_inline_input.send_keys(new_name)

        # click submit
        el_submit = self.driver.find_element_by_css_selector(
            'tr[data-display="{0}"] '.format(old_name) +
            'td[data-cell-name="name"] .inline-edit-actions' +
            ' button[type="submit"]')
        el_submit.click()
开发者ID:mssumanth,项目名称:Temp,代码行数:27,代码来源:base.py

示例5: _drag_page_el_2_page_el

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
    def _drag_page_el_2_page_el(step, elemant_name_src, element_name_target):
        src = get_visible_page_element(elemant_name_src)
        target = get_visible_page_element(element_name_target)

        action_chain = ActionChains(world.browser.driver)
        action_chain.drag_and_drop(src, target)
        action_chain.perform()
开发者ID:mroohian,项目名称:Leaf,代码行数:9,代码来源:mouse.py

示例6: search_field_focus

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
 def search_field_focus(self):
     plaform_submenu_trigger = self.find_element(*self._platform_submenu_trigger_locator)
     search_field = self.find_element(*self._search_field_locator)
     focus = ActionChains(self.selenium).move_to_element(search_field).click()
     focus.perform()
     # this can be a bit flaky sometimes
     self.wait.until(lambda s: not plaform_submenu_trigger.is_displayed())
开发者ID:safwanrahman,项目名称:kuma,代码行数:9,代码来源:base.py

示例7: move_to_element

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
def move_to_element(loc, **kwargs):
    """
    Moves to an element.

    Args:
        loc: A locator, expects either a string, WebElement, tuple.
    Returns: It passes `loc` through to make it possible to use in case we want to immediately use
        the element that it is being moved to.
    """
    brand = "//div[@id='page_header_div']//div[contains(@class, 'brand')]"
    wait_for_ajax()
    el = element(loc, **kwargs)
    move_to = ActionChains(browser()).move_to_element(el)
    try:
        move_to.perform()
    except MoveTargetOutOfBoundsException:
        # ff workaround
        execute_script("arguments[0].scrollIntoView();", el)
        if elements(brand) and not is_displayed(brand):
            # If it does it badly that it moves whole page, this moves it back
            try:
                execute_script("arguments[0].scrollIntoView();", element(brand))
            except MoveTargetOutOfBoundsException:
                pass
        move_to.perform()
    return el
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:28,代码来源:pytest_selenium.py

示例8: test_filter_tenants

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
 def test_filter_tenants(self):
     driver = self.driver
     driver.maximize_window()
     driver.get(self.base_url + "/")
     driver.find_element_by_name("username").send_keys(config.username)
     driver.find_element_by_name("password").send_keys(config.password)
     driver.find_element_by_css_selector("input.loginSubmit").click()
     Move = ActionChains(driver).move_to_element(driver.find_element_by_link_text("Settings"))
     Move.perform()
     driver.find_element_by_link_text("Tenants").click()
     driver.find_element_by_link_text("Create Tenant").click()
     driver.find_element_by_id("name").send_keys("Test_tenant")
     driver.find_element_by_id("description").send_keys("Test_description")
     driver.find_element_by_id("enabled").click()
     driver.find_element_by_name("_action_save").click()
     driver.find_element_by_xpath("//div/input[@type='text']").send_keys("Test_tenant")
     time.sleep(1)
     self.assertTrue(driver.find_element_by_xpath("//tbody/tr/td[text()='Test_tenant']").is_displayed())
     self.assertFalse(driver.find_element_by_xpath("//tbody/tr/td[text()='services']").is_displayed())
     _all_elem  = len(driver.find_elements_by_xpath("//tbody/tr"))
     _elem_disp = len(driver.find_elements_by_xpath("//tbody/tr[@style='display: none;']"))
     self.assertTrue(_all_elem - _elem_disp==int(driver.find_elements_by_xpath("//div/label")[1].text))
     elements = driver.find_elements_by_xpath("//tbody/tr/td/a")
     time.sleep(1)
     for i in elements:
         if i.is_displayed() != 0:
             i.click()
             break
     time.sleep(5)
     driver.find_element_by_xpath('//*[@id="delete"]/span/div').click()
     driver.find_element_by_xpath('//*[@id="btn-confirm"]/span').click()
     #alert = driver.switch_to_alert()
     #alert.accept()
     self.assertFalse(self.is_element_present(By.XPATH, "//tbody/tr/td[text()='Test_tenant']"))
开发者ID:BillTheBest,项目名称:aurora,代码行数:36,代码来源:test_filter_tenants.py

示例9: test_page_elements

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
    def test_page_elements(self):
        go_to('http://www.ncbi.nlm.nih.gov/m/pubmed')
        assert_title('PubMed Mobile')
        ele = self.browser.find_element_by_id('srch')

        h = ActionChains(self.browser).move_to_element( ele )
        h.perform()
开发者ID:edwelker,项目名称:functional_web_tests,代码行数:9,代码来源:test_self.py

示例10: move

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
 def move(self, delta_x, delta_y):
     """ Move dialog. """
     chain = ActionChains(self.browser)
     chain.click_and_hold(self('dialog_title').element)
     chain.move_by_offset(delta_x, delta_y)
     chain.release(None)
     chain.perform()
开发者ID:akhi28,项目名称:OpenMDAO-Framework,代码行数:9,代码来源:dialog.py

示例11: init_browser

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

示例12: goto_options_item

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
    def goto_options_item(self, link):
        """click on a group management option link"""

        if not link in self._links:
            raise ValueError("invalid link name: '%s'", link)

        base = self.owner.find_element(self.locators["base"])

        # hover mouse over the group manager toolbar to expand it
        actionProvider = ActionChains(self.owner._browser).move_to_element(base)
        self.logger.debug("moving mouse over options dropdown")
        actionProvider.perform()
        # move the mouse to the correct link and click it
        loc = self.locators[link]
        e = self.owner.find_element(loc, base)
        # moving to the element does not work in this case
        # I think because the browser's popup window for the url
        # blocks the element? either way, we can click the element
        # just by having the options menu open.
        # actionProvider = ActionChains(self.owner._browser)\
        #                 .move_to_element(e)
        # actionProvider.perform()
        self.owner.wait_for_page_element_displayed(loc)
        self.logger.debug("clicking drowdown menu option '%s': %s" % (link, loc))
        e.click()
开发者ID:codedsk,项目名称:hubcheck,代码行数:27,代码来源:groups_options.py

示例13: hover_and_click

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
def hover_and_click(driver, hover_selector, click_selector,
                    hover_by=By.CSS_SELECTOR, click_by=By.CSS_SELECTOR,
                    timeout=settings.SMALL_TIMEOUT):
    """
    Fires the hover event for a specified element by a given selector, then
    clicks on another element specified. Useful for dropdown hover based menus.
    @Params
    driver - the webdriver object (required)
    hover_selector - the css selector to hover over (required)
    click_selector - the css selector to click on (required)
    hover_by - the method to search by (Default: By.CSS_SELECTOR)
    click_by - the method to search by (Default: By.CSS_SELECTOR)
    timeout - number of seconds to wait for click element to appear after hover
    """
    start_ms = time.time() * 1000.0
    stop_ms = start_ms + (timeout * 1000.0)
    element = driver.find_element(by=hover_by, value=hover_selector)
    hover = ActionChains(driver).move_to_element(element)
    hover.perform()
    for x in range(int(timeout * 10)):
        try:
            element = driver.find_element(by=click_by,
                                          value="%s" % click_selector).click()
            return element
        except Exception:
            now_ms = time.time() * 1000.0
            if now_ms >= stop_ms:
                break
            time.sleep(0.1)
    raise NoSuchElementException(
        "Element {%s} was not present after %s seconds!" %
        (click_selector, timeout))
开发者ID:VegiS,项目名称:SeleniumBase,代码行数:34,代码来源:page_actions.py

示例14: hoveroverthis

# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import perform [as 别名]
def hoveroverthis(bafc,thingtodo,item,number,testname="NONE", snap="PIC",teststatus="passed"):
	driver = bafc[0]
	action = "hoveroverthis_" + thingtodo

	elements = getelements(driver,thingtodo,item)[0]
	teststatus = getelements(driver,thingtodo,item)[1]

	try:

		if number != "loop":
			print("Hovering over ",thingtodo,":  ",item, " number:  ",number)
			i=int(number)
			hover = ActionChains(driver).move_to_element(elements[i])
			hover.perform()	
			snapit(bafc,"hoveroverthis_" + thingtodo,testname,action,snap,teststatus)
		if number == "loop":
			these = len(elements)
			for i in range(0,these):
				print("Hovering over ",thingtodo,":  ",item, " number:  ",i)
				hover = ActionChains(driver).move_to_element(elements[i])
				hover.perform()	
				time.sleep(5)
				snapit(bafc,"hoveroverthis_" + thingtodo + "_" + str(i),testname,action,snap,teststatus)

	except:
			teststatus = "failed"
			snapit(bafc,"hoveroverthis_" + thingtodo,testname,action,snap,teststatus)
开发者ID:zgeek3,项目名称:quickswd_python,代码行数:29,代码来源:SELENIUM_functions.py

示例15: parse

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


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