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


Python ActionChains.perform方法代码示例

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


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

示例1: click_img

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def click_img(self, answer, height, identify_img_xpath1=None,
                  identify_button_xpath=None):
        """
        根据打码返回的坐标进行点击操作
        仅适用与点击型验证码

        :param answer: 打码返回结果
        :param height: 答案高度
        :param identify_img_xpath1: 题目xpath
        :param identify_button_xpath: 验证按钮
        :return:
        """
        actions = ActionChains(self.driver)
        img = self.driver.find_element_by_xpath(identify_img_xpath1)
        points = answer.split('|')
        for point in points:
            x, y = eval(point)
            actions.move_to_element_with_offset(
                img, x, y - int((height / self.device_pixel_ratio)))
            actions.click()
        actions.perform()
        time.sleep(2)
        if not identify_button_xpath:
            return
        self.driver.find_element_by_xpath(identify_button_xpath).click()
开发者ID:wuyue92tree,项目名称:crwy,代码行数:27,代码来源:selenium_api.py

示例2: test_student_find_the_cc_book_from_an_online_search_7742

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

示例3: bing_search

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
def bing_search(start, end):
    # Generator: yield the url for beautifulsoup
    global number_of_urls_to_search
    local_count = number_of_urls_to_search
    driver = webdriver.PhantomJS(executable_path='D:/phantomjs-2.1.1-windows/bin/phantomJS')
    driver.get("http://global.bing.com/?FORM=HPCNEN&setmkt=en-us&setlang=en-us")
    try:
        element = WebDriverWait(driver, 10).until(
                EC.presence_of_element_located((By.ID, "sb_feedback")))
    except:
        raise
    finally:
        searchField = driver.find_element(By.ID, "sb_form_q")
        submitButton = driver.find_element(By.ID, "sb_form_go")
    actions = ActionChains(driver).click(searchField).send_keys(start + " " + end + " " + "text").click(submitButton)
    actions.perform()
    try:
        element = WebDriverWait(driver, 20).until(
                EC.presence_of_element_located((By.CLASS_NAME, "b_footerRight")))
    except:
        raise
    finally:
        bsObj = BeautifulSoup(driver.page_source, 'html.parser')
    results = bsObj.findAll('li', {'class': 'b_algo'})
    for result in results:
        if not local_count:
            driver.close()
            return
        print(result.a['href'])
        yield result.a['href']
        local_count -= 1
    driver.close()
开发者ID:Weiming-Hu,项目名称:text-based-six-degree,代码行数:34,代码来源:find_path_server.py

示例4: go_to_my_room

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
 def go_to_my_room(self):
     self.wait_element_click(self.AVATAR)
     room = self.driver.find_element_by_xpath(self.AVATAR)
     mv = ActionChains(self.driver).move_to_element(room)
     mv.perform()
     room.click()
     return MyRoomPage(self.driver)
开发者ID:Vasiliy-tech,项目名称:home-assignment-4,代码行数:9,代码来源:main_page.py

示例5: test_search_in_python_org

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def test_search_in_python_org(self):
        driver = self.driver
        driver.implicitly_wait(5)
        actions = ActionChains(driver)
        driver.get("http://localhost:8080")

        value = driver.find_element_by_css_selector('.graph')
        actions.click(on_element=value)
        actions.perform()

        menu = driver.find_element_by_id('VIZ_popup_menu')
        buttons = driver.find_elements_by_css_selector('#VIZ_popup_menu button')
        for button in buttons:
            text = button.get_attribute('textContent')
            if text == 'Set range':
                button.click()
                WebDriverWait(driver, 5).until(EC.alert_is_present())
                alert = driver.switch_to_alert()
                alert.send_keys("-0.1,0.1")
                alert.accept()
                break
                
        tick = driver.find_element_by_css_selector('g.axis:nth-child(4) > g:nth-child(1)')
        text = tick.get_attribute('textContent')
        assert text == "-0.1"
开发者ID:Seanny123,项目名称:gui_test,代码行数:27,代码来源:set_range_test.py

示例6: test_tamplate

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def test_tamplate(self):
        ''' Test a situation when unlogged user tries to download a file '''
        item_to_download = WebDriverWait(self.driver, 10).until(
            ec.visibility_of_element_located((By.CLASS_NAME, 'ent-title')))
        
        action = ActionChains(self.driver)
        action.move_to_element(item_to_download)
        action.click(item_to_download)
        action.perform()

        time.sleep(5)

        download_button = self.driver.find_elements_by_class_name('download')
        download_button_1 = download_button[0]
        download_button_2 = download_button[1]

        action = ActionChains(self.driver)
        action.move_to_element(download_button_2)
        action.click(download_button_2)
        action.perform()
        time.sleep(8)

        #Alert message
        try:
            alert_message = WebDriverWait(self.driver, 10).until(
            ec.visibility_of_element_located((By.CLASS_NAME, 'xw-hdr-text')))
        finally:
            print ('oops')
开发者ID:dmytrobondarchuk,项目名称:7themes_tests,代码行数:30,代码来源:test_download_file_unlogged_user.py

示例7: _select_case

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def _select_case(self, suite, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(suite))
        time.sleep(1)

        checkbox = None
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if elem.text.startswith(case):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not self.wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
            raise Exception('Failed to start test case')
开发者ID:MatthewCoppola4,项目名称:openthread,代码行数:33,代码来源:harness_case.py

示例8: add_library_item_to_dataflow

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def add_library_item_to_dataflow(self, item_name, instance_name, check=True, offset=None, prefix=None):
        """ Add component `item_name`, with name `instance_name`. """
        library_item = self.get_library_item(item_name)

        target = WebDriverWait(self.browser, TMO).until(
            lambda browser: browser.find_element_by_xpath("//*[@id='-dataflow']")
        )

        offset = offset or (90, 90)
        chain = ActionChains(self.browser)
        if False:
            chain.drag_and_drop(library_item, target)
        else:
            chain.click_and_hold(library_item)
            chain.move_to_element_with_offset(target, offset[0], offset[1])
            chain.release(None)
        chain.perform()

        page = ValuePrompt(self.browser, self.port)
        page.set_value(instance_name)
        # Check that the prompt is gone so we can distinguish a prompt problem
        # from a dataflow update problem.
        time.sleep(0.25)
        self.browser.implicitly_wait(1)  # We don't expect to find anything.
        try:
            eq(len(self.browser.find_elements(*page("prompt")._locator)), 0)
        finally:
            self.browser.implicitly_wait(TMO)

        retval = None
        if check:  # Check that it's been added.
            retval = WebDriverWait(self.browser, TMO).until(
                lambda browser: self.get_dataflow_figure(instance_name, prefix)
            )
        return retval
开发者ID:RacerXFD,项目名称:OpenMDAO-Framework,代码行数:37,代码来源:workspace.py

示例9: find_soup

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
def find_soup(domain_name, driver, form_name):
    # element_to_be_clickable, presence_of_element_located
    WebDriverWait(driver, MAX_WAIT).until(EC.element_to_be_clickable((By.ID, form_name)))
    domain_form = driver.find_element_by_id(form_name)
    WebDriverWait(driver, MAX_WAIT).until(EC.element_to_be_clickable((By.ID, form_name)))
    domain_form.clear()

    type_new = ActionChains(driver).click(domain_form).send_keys(domain_name)
    type_new.perform()
   
    driver.implicitly_wait(0.1)
    wait_attempts = 0
    while domain_form.get_attribute('value') != domain_name:
        driver.implicitly_wait(5)
        wait_attempts += 1
        if wait_attempts > WAIT_ATTEMPTS:
            break

    submit_new = ActionChains(driver).click(domain_form).send_keys(Keys.ENTER)
    submit_new.perform()

    WebDriverWait(driver, MAX_WAIT).until(EC.element_to_be_clickable((By.ID, "domain_search_input")))

    source = driver.page_source
    soup = BeautifulSoup(source, "html.parser")

    godaddy_link = 'https://www.godaddy.com/domains/searchresults.aspx?checkAvail=1&domainToCheck=' + domain_name

    # Can't do the following b/c the browser url doesn't change when editing form within page: godaddy_link = driver.current_url

    return soup, godaddy_link, driver
开发者ID:roesler-stan,项目名称:GoDaddy,代码行数:33,代码来源:memory_test.py

示例10: add_object_to_workflow_figure

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def add_object_to_workflow_figure(self, obj_path, target_name, target_page=None):
        """ Add `obj_path` object to `target_name` in workflow diagram. """

        if target_page is None:
            target_page = self

        for retry in range(3):
            try:
                items = obj_path.split('.')
                parent = items[:-1]
                comp = items[-1]
                obj = self.get_dataflow_figure(comp, parent)

                workflow = target_page.get_workflow_figure(target_name)
                flow_fig = workflow.flow

                chain = ActionChains(self.browser)
                chain.drag_and_drop(obj.root, flow_fig)
                chain.perform()
            except StaleElementReferenceException:
                if retry < 2:
                    logging.warning('add_object_to_workflow_figure:'
                                    ' StaleElementReferenceException')
                else:
                    raise
            else:
                break
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:29,代码来源:workspace.py

示例11: add_object_to_workflow

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def add_object_to_workflow(self, obj_path, target_name):
        """ Add `obj_path` object to `target_name` in workflow. """
        for retry in range(3):
            try:
                items = obj_path.split('.')
                parent = items[:-1]
                comp = items[-1]
                obj = self.get_dataflow_figure(comp, parent)

                target = self.find_object_button(target_name)

                chain = ActionChains(self.browser)
                chain.drag_and_drop(obj.root, target)
                chain.perform()

                #obj = self.find_object_button(obj_path)
                #workflow = self.get_workflow_figure(target_name)
                #flow_fig = workflow.flow
                #chain = ActionChains(self.browser)
                #chain.move_to_element(obj)
                #chain.click_and_hold(obj)
                #chain.move_to_element(flow_fig)
                #chain.move_by_offset(2, 1)
                #chain.release(None)
                #chain.perform()
            except StaleElementReferenceException:
                if retry < 2:
                    logging.warning('add_object_to_workflow:'
                                    ' StaleElementReferenceException')
                else:
                    raise
            else:
                break
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:35,代码来源:workspace.py

示例12: _select_case

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def _select_case(self, role, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(role))
        time.sleep(1)

        checkbox = None
        wait_until(lambda: self._browser.find_elements_by_css_selector('.tree-node .tree-title') and True)
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        finder = re.compile(r'.*\b' + case + r'\b')
        finder_dotted = re.compile(r'.*\b' + case.replace(' ', r'\.') + r'\b')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if finder.match(elem.text) or finder_dotted.match(elem.text):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        self._browser.execute_script("$('.overview').css('left', '0')")
        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
            raise Exception('Failed to start test case')
开发者ID:pvanhorn,项目名称:openthread,代码行数:37,代码来源:harness_case.py

示例13: click_menu_option_by_visible_text

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def click_menu_option_by_visible_text(self, menu_locator, list_of_menu_options):
        """
        Performs support move_to_element action on every link <support...> 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.

        :param menu_locator:
        :param list_of_menu_options: 
        """
        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:LorenaH,项目名称:TN-Automatizacion,代码行数:28,代码来源:basepage.py

示例14: test_event_detail_page_tab2

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import perform [as 别名]
    def test_event_detail_page_tab2(self):
        """
        Test that the adverse event page has the tab and accordion items we expect
        :return:
        """
        # I want to see the top drugs that have a given adverse event
        # I want to see the sex and age breakdown of the top drugs that have a given adverse event

        item = CATEGORIES[1]
        self.driver.get('%s/search/events/?q=%s' % (self.live_server_url, item['search'], ))
        self.assertIn(item['detail'], self.driver.find_element_by_tag_name('h1').text)
        self.assertIn(item['search'], self.driver.find_element_by_tag_name('h1').text)

        # we should have two tabs
        self.assertEqual(2, len(self.driver.find_element_by_class_name('ui-tabs-nav').find_elements_by_tag_name('li')))

        # I want to see drugs with this adverse event, so i click that tab
        self.driver.find_element_by_id('ui-id-2').click()

        # I see a chart with drug information and I click and mouse over the first bar to get the count
        chart_bar = self.driver.find_element_by_xpath(
            "//div[@id='adverseChart']//*[local-name()='svg']//*[local-name()='g'][@class='highcharts-series highcharts-tracker']/*[local-name()='rect']")
        chart_bar.click()
        hover = ActionChains(self.driver).move_to_element(chart_bar)
        hover.perform()

        tool_tip = WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located((By.XPATH, "//div[@class='highcharts-tooltip']/span/div/span")))
        self.assertEqual('Count', tool_tip.text)
开发者ID:artemis-consulting,项目名称:prototype-pool3,代码行数:31,代码来源:test_behavior.py

示例15: visit

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


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