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


Python ActionChains.move_to_element方法代码示例

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


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

示例1: test_LoginRead

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
 def test_LoginRead(self):#第二种方法,见main里的注释
     cdr=self.cdr
     Url=self.Url
     cdr.get(Url)
     #cdr.implicitly_wait(5)
     WebDriverWait(cdr,10).until(lambda cdr:cdr.find_element_by_xpath(".//*[@id='J_connect']/div[2]/div/div/span/a[2]"))
     
     fopen=open(r".\something\username.txt","r")
     for us in fopen:#------这里是从文件里进行读取
         time.sleep(2)
         cdr.find_element_by_xpath(".//*[@id='J_connect']/div[2]/div/div/span/a[2]").click()#点击登录
         
         WebDriverWait(cdr,10).until(lambda cdr:cdr.find_element_by_id("email_login"))
         cdr.find_element_by_id("email_login").click()#点击使用邮箱登陆
         print cdr.find_element_by_id("email_login").get_attribute("title")
         
         #输入用户名密码
         time.sleep(2)
         cdr.find_element_by_id("login_email").send_keys(us)
         print "登录用户名为:"+us
         cdr.find_element_by_id("login_password").send_keys("123456")
         cdr.find_element_by_id("remember_me").click()#去掉记住登陆 checkbox
         #点击登录按钮
         cdr.find_element_by_id("login").click()
         
         time.sleep(5)
         #鼠标移动到 头像旁边的下落箭头上
         action=ActionChains(cdr)
         action.move_to_element(cdr.find_element_by_xpath("//div[@class='tr']/div/span[2]")).perform()
         #下拉菜单点击 退出帐号
         cdr.find_element_by_xpath("//div[@class='tr']/div/span[3]/ul/li[4]/a").click()
     fopen.close()
开发者ID:xlmysjz,项目名称:Python,代码行数:34,代码来源:LoginTopka.py

示例2: _select_case

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

示例3: _select_case

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

示例4: click_menu_option_by_visible_text

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

示例5: _test_reorder_file_bar

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
    def _test_reorder_file_bar(self, page):
        page.add_file([x for x in FILES if x.name == 'test.jpg'][0])

        WebDriverWait(page.driver, 3).until(
            ec.visibility_of_element_located(
                (
                    By.CSS_SELECTOR,
                    'div.grid-canvas div.ui-widget-content.slick-row.odd'
                )
            )
        )

        ac = ActionChains(page.driver)
        a = page.driver.find_elements_by_css_selector(
            'DIV.container DIV.slick-header.ui-state-default DIV.slick-header-columns.ui-sortable SPAN.slick-column-name'
        )[3]
        b = page.driver.find_elements_by_css_selector(
            'DIV.container DIV.slick-header.ui-state-default DIV.slick-header-columns.ui-sortable SPAN.slick-column-name'
        )[0]

        ac.click_and_hold(a).perform()
        a_chain = ActionChains(page.driver)
        a_chain.move_to_element(b).perform()
        a_chain.release(b).perform()

        downloads = page.driver.find_element_by_css_selector(
            'div.grid-canvas div.ui-widget-content.slick-row.odd DIV.slick-cell.l0.r0'
        ).text

        self.assertIn('0', downloads)

        page.close()
开发者ID:chennan47,项目名称:osf-ui-tests,代码行数:34,代码来源:file_tests.py

示例6: test_tamplate

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

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
def test_basic_functionality(driver, test_file):
	try:
		#Test page response by clicking the reset button and applying new code to ace-editor

		tt.reset_page(driver)
		tt.update_editor(driver, test_file)
		ens_elements = driver.find_elements_by_xpath('//*[@class="ens"]')
		assert (len(ens_elements) > 0)
		side_script = '''var right = document.getElementById("rightpane"); \
		right.style.width = "200px"
		'''
		driver.execute_script(side_script)

		#Creates graph objects by right clicking on nodes and selecting from menu
		actions = ActionChains(driver)
		elements = ['node', 'ens']
		for elem in elements:
			node = driver.find_element_by_xpath('//*[@class="'+elem+'"]')
			actions = ActionChains(driver)
			actions.move_to_element(node)
			actions.context_click()
			actions.perform()
			time.sleep(1)
			actions = ActionChains(driver)

			menu = driver.find_element_by_xpath('//*[@class="dropdown-menu"]/li[1]')
			actions.move_to_element(menu)
			actions.click()
			actions.perform()
			time.sleep(0.5)

		graph_elements = driver.find_elements_by_xpath('//*[@class="graph"]')

		assert len(graph_elements) > 0
		tt.start_stop_sim(driver)
		time.sleep(1.5)
		tt.start_stop_sim(driver)
		time.sleep(0.5)

		ticker = driver.find_element_by_xpath('//*[@id="ticks_tr"]/td')
		sim_time = ticker.get_attribute('textContent')

		assert (float(sim_time) > 0)

	except Exception as e:
		#Travis Only: On fail takes screenshot and uploads it to imgur


		if('TRAVIS' in os.environ):
			tt.imgur_screenshot(driver)

		_, _, tb = sys.exc_info()
		traceback.print_tb(tb) # Fixed format
		tb_info = traceback.extract_tb(tb)
		filename, line, func, text = tb_info[-1]

		print('An error occurred on line {} in statement {}'.format(line, text))
		print(str(e))
		exit(1)
开发者ID:amshenoy,项目名称:nengo_gui,代码行数:61,代码来源:test_basic_functionality.py

示例8: implicit_click

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
    def implicit_click(self, item):
        actions = ActionChains(self._driver)
        with wait_for_element_visibility(self._driver, item):
            actions.move_to_element(self._base).click().perform()

        # It is needed to clean ActionChains instance after each call of preform()
        actions = ActionChains(self._driver)
        actions.move_to_element(item).click().perform()
开发者ID:AButenko,项目名称:selenium_tests,代码行数:10,代码来源:header.py

示例9: click

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
 def click(self, element):
     # Although elements have a click method, it seems to play up, possibly
     # when browser loses focus. Search for "selenium missing click" to get
     # an idea of the problem. Most complaints are on IE, but Chrome seems
     # susceptible as well. The incantation below, with the move operation
     # before the click, seems to work more reliably.
     action_chains = ActionChains(self.browser)
     action_chains.move_to_element(element).click().perform()
开发者ID:BioVeL,项目名称:portal-tests,代码行数:10,代码来源:PortalBrowser.py

示例10: stop

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
def stop():
	main_window = driver.current_window_handle
	driver.switch_to_window(main_window)
	actions = ActionChains(driver)
	stop = driver.find_element_by_xpath("//span[contains(text(), 'stop')]")
	actions.move_to_element(stop)
	actions.click(stop)
	actions.perform()
开发者ID:JJ97,项目名称:Hash,代码行数:10,代码来源:Auto.py

示例11: setInputText

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
 def setInputText(self, name, value):
     textArea = self.workflow_input.find_element_by_xpath(
         './*[@data-input-name="{0}"]//textarea'.format(name)
         )
     action_chains = ActionChains(self.portal.browser)
     action_chains.move_to_element(textArea).click().send_keys(
         Keys.BACK_SPACE*len(textArea.text)+str(value)
         ).perform()
开发者ID:BioVeL,项目名称:portal-tests,代码行数:10,代码来源:PortalBrowser.py

示例12: do_it

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
 def do_it(self):
     
     mouse_move_to_menu_themes = ActionChains(self.driver)
     #mouse_move_to_menu_themes.move_to_element(self.menu)
     mouse_move_to_menu_themes.move_to_element(self.tab)
     mouse_move_to_menu_themes.move_to_element(self.subitem)
     mouse_move_to_menu_themes.click(self.subitem)
     mouse_move_to_menu_themes.perform()
     time.sleep(5)
开发者ID:dmytrobondarchuk,项目名称:7themes_tests,代码行数:11,代码来源:serfing_links_Test_Case_old.py

示例13: create_rerun

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
 def create_rerun(self, course_key):
     """
     Clicks the create rerun link of the course specified by course_key
     'Re-run course' link doesn't show up until you mouse over that course in the course listing
     """
     actions = ActionChains(self.browser)
     button_name = self.browser.find_element_by_css_selector('.rerun-button[href$="' + course_key + '"]')
     actions.move_to_element(button_name)
     actions.click(button_name)
     actions.perform()
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:12,代码来源:index.py

示例14: test_example

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
def test_example(driver):
	# Always include driver as a function parameter.
	# This is the selenium webdriver that will allow
	# you to interact with the webpage.

	tt.reset_page(driver)
	# Most testing_tools functions require driver as an input.
	# Presses the reset button to start the page fresh.
	# Usually useful but not always needed.
	# More documentation on testing_tools can be found
	# in nengo_gui/testing_tools.py

	time.sleep(1)
	# Waits a small amount of time to ensure the page has
	# time to reset.

	tt.update_editor(driver,'''
import nengo

model = nengo.Network()
with model:
    stim = nengo.Node([0])
    a = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim, a)
		''')
	# The page will now load this code into the code editor

	stim = driver.find_element_by_xpath('//*[@class="node"]')
	a = driver.find_element_by_xpath('//*[@class="ens"]')
	# Finds the 'stim' and 'a' nodes and saves them as a webElements.

	action = ActionChains(driver)
	# ActionChains allow you to link together multiple mouse events
	# then execute them in that order.

	action.move_to_element(stim);
	action.context_click()
	action.perform()
	time.sleep(1)
	# The stim element has now been right clicked.

	# WARNING: when using ActionChains reinitialize ActionChains
	# after every .perform() call, it is not clear why but
	# ActionChains does not seem to reset properly after this call.

	right_click_menu = driver.find_element_by_xpath('//*[@class="dropdown-menu"]')

	assert(bool(stim) and bool(a) == True)
	# Tests if both elements are present.

	assert(bool(right_click_menu) == True)
	# Tests if stim has been properly clicked

	if('TRAVIS' in os.environ): ########## TRAVIS ONLY
		tt.imgur_screenshot(driver)
开发者ID:amshenoy,项目名称:nengo_gui,代码行数:57,代码来源:test_example.py

示例15: runTest

# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import move_to_element [as 别名]
 def runTest(self):
     print('Checking overview page')
     action_chains = ActionChains(self.driver)
     status_menu = self.driver.find_element_by_xpath("//ul/li/a[contains(text(),'Status')]")
     overview_menu = self.driver.find_element_by_xpath("//ul/li/a[contains(text(),'Overview')]")
     action_chains.move_to_element(status_menu).click(overview_menu).perform()
     self.assertIn('Overview', self.driver.title)
     print('Managed to switch to overview page')
     for i in [ 'System', 'Memory', 'Network', 'DHCP Leases' ]:
         self.driver.find_element_by_xpath("//fieldset/legend[contains(text(),'" + i + "')]")
         print(' * overview page contains section ' + i)
开发者ID:fasolens,项目名称:boardfarm,代码行数:13,代码来源:webui_tests.py


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