本文整理汇总了Python中selenium.webdriver.common.action_chains.ActionChains.move_to_element方法的典型用法代码示例。如果您正苦于以下问题:Python ActionChains.move_to_element方法的具体用法?Python ActionChains.move_to_element怎么用?Python ActionChains.move_to_element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.common.action_chains.ActionChains
的用法示例。
在下文中一共展示了ActionChains.move_to_element方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chat_date
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def chat_date(self):
driver = self.driver
try:
driver.find_element_by_id(cit).click()
time.sleep(1)
driver.find_element_by_css_selector("div#" + ciw + " i.icon-create-network").click()
chain = ActionChains(driver)
me = driver.find_element_by_xpath(
"/html/body/form/div[5]/div/div/div[2]/div[@id='" + ciw + "']/div[1]/div[3]/div/div[1]/div/div/ul/li[2]"
)
chain.move_to_element(me).perform()
time.sleep(2)
driver.find_element_by_css_selector("div#" + ciw + " li.menuItem.btnNewSchedule").click()
time.sleep(3)
datename = time.ctime()
member = Config.member
Funtion.datedata(datename, *member)
time.sleep(3)
try:
driver.find_element_by_xpath('//div[@class="cardContent"][text()="' + datename + '"]')
cdr = "PASS"
except:
cdr = "FAIL"
except:
cdr = "DONE"
return cdr
示例2: 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 move_to_element [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")
示例3: post_reply
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def post_reply(self):
driver = self.driver
try:
time.sleep(2)
#获取动态data-reactid
idaa = driver.find_element_by_xpath("/html/body/form/div[5]/div[1]/div/div[2]/div[1]/div[1]/div/ul/li[1]/div[2]/div[1]/div/div/div/div[contains(text(),\"" + messagenow + "\")]").get_attribute("data-reactid")
idab = idaa[0:54]
idbb = idab + "1.4.2.0.0.0.0.0"
messagenow1 = time.ctime() #回复动态的内容
#页面移动到回复动态的地方-解决无法点击的问题
chain = ActionChains(driver)
me = driver.find_element_by_css_selector("[data-reactid=\"" + idbb + "\"]")
chain.move_to_element(me).perform()
driver.find_element_by_css_selector("[data-reactid=\"" + idbb + "\"]").send_keys(messagenow1) #输入回复动态内容
idbc = idab + "1.4.2.0.1.0.3"
driver.find_element_by_css_selector("[data-reactid=\"" + idbc + "\"]").click() #点击回复
time.sleep(2)
for i in range(0,10):
try: #验证回复是否成功
driver.find_element_by_xpath("/html/body/form/div[5]/div/div/div[2]/div[1]/div[1]/div/ul/li[1]/div[2]/div/ul/li/div/div/div/span[contains(text(),\"" + messagenow1 + "\")]")
rtt="PASS"
break
except:
rtt="FAIL"
time.sleep(1)
except:
rtt="DONE"
return rtt
示例4: parse
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [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
示例5: click_menu_option_by_visible_text
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [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()
示例6: test_verify_link_created
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def test_verify_link_created(self):
driver = self.driver
links = wait.until(EC.visibility_of_element_located((By.ID, 'menu-links')))
actions = ActionChains(driver)
actions.move_to_element(links)
actions.perform()
wait.until(EC.visibility_of_element_located((By.LINK_TEXT, 'All Links'))).click()
links_table = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.wp-list-table.widefat.fixed.bookmarks')))
actions = ActionChains(driver)
actions.move_to_element(links_table)
actions.perform()
table_body = links_table.find_element_by_tag_name('tbody')
table_body_rows = table_body.find_elements_by_tag_name('tr')
for row_values in table_body_rows:
##make th list
title = driver.find_elements_by_tag_name('td')
# title = driver.find_element_by_tag_name('th')
title_text = title[0].text
print(title_text)
print(link_heading)
assert title_text == link_heading
if True:
print(title_text)
table_body_row_td_values = row_values.find_elements_by_tag_name('td')
for row_td_value in table_body_row_td_values:
print(row_td_value.text)
if False:
print()
示例7: test_click_links
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def test_click_links(self):
driver = self.driver
links = wait.until(EC.visibility_of_element_located((By.ID, 'menu-links')))
actions = ActionChains(driver)
actions.move_to_element(links)
actions.perform()
wait.until(EC.visibility_of_element_located((By.LINK_TEXT, 'All Links'))).click()
示例8: modelWalker
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [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()
示例9: with_open_in_new_window
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def with_open_in_new_window(self, element, callback_, *args, **kwargs):
"""Shift-clicks on an element to open a new window,
calls the callback function, and then closes the
window and returns.
This is useful for iterating through a link tree
we cannot easily step back in (e.g. where the starting
the result of a POST request)
Callback function is called like this: `callback(Surfer, arguments)`
with a Surfer object placed in the new window
Returns the result of `callback`
"""
try:
actions = ActionChains(self.selenium_driver)
actions.move_to_element(element).perform()
self._scroll_element_into_view(element)
element.send_keys(Keys.SHIFT + Keys.ENTER)
except ElementNotVisibleException:
raise
self.selenium_driver.implicitly_wait(self.extra_delay)
sleep(self.extra_delay) # implicitly_wait doesn't work on FF?
windows = self.selenium_driver.window_handles
self.selenium_driver.switch_to_window(windows[-1])
if len(windows) > 1:
res = callback_(self, *args, **kwargs)
self.selenium_driver.close()
windows = self.selenium_driver.window_handles
self.selenium_driver.switch_to_window(windows[-1])
return res
示例10: test_pagetable_heading
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def test_pagetable_heading(self):
driver = self.driver
page_table = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.wp-list-table.widefat.fixed.pages')))
actions = ActionChains(driver)
actions.move_to_element(page_table)
actions.perform()
heading = page_table.find_element_by_tag_name('thead')
row = heading.find_element_by_tag_name('tr')
th = []
th = row.find_elements_by_tag_name('th')
# print(th.text)
# td = []
# td = row.find_elements_by_tag_name('td')
assert th[0].text == "Select All"
if True:
print("At th[0] text is"+ th[0].text)
assert th[1].text == "Title"
assert th[2].text == "Author"
assert th[3].text == ""
assert th[4].text == "Date"
assert th[5].text == "Views"
assert th[6].text == "SEO"
assert th[7].text == "SEO Title"
assert th[8].text == "Meta Desc."
assert th[9].text == "Focus KW"
for th_value in th:
print(th_value.text)
示例11: chat_task
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def chat_task(self):
driver = self.driver
try:
driver.find_element_by_id(cit).click()
tasktitle = time.ctime()
time.sleep(1)
driver.find_element_by_css_selector("div#" + ciw + " i.icon-create-network").click()
chain = ActionChains(driver)
me = driver.find_element_by_xpath(
" /html/body/form/div[5]/div/div/div[2]/div[@id='"
+ ciw
+ "']/div[1]/div[3]/div/div[1]/div/div/ul/li[1]"
)
chain.move_to_element(me).perform()
time.sleep(2)
driver.find_element_by_css_selector("div#" + ciw + " li.menuItem.btnNewTask").click()
time.sleep(3)
driver.find_element_by_id("txtTaskName").click()
driver.find_element_by_id("txtTaskName").clear()
driver.find_element_by_id("txtTaskName").send_keys(tasktitle)
time.sleep(1)
driver.find_element_by_link_text(u"创建").click()
time.sleep(2)
try:
driver.find_element_by_xpath('//div[@class="cardContent"][text()="' + tasktitle + '"]')
ctr = "PASS"
except:
ctr = "FAIL"
except:
ctr = "DONE"
return ctr
示例12: testRegister
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [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-')
示例13: mouse_over
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [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()
示例14: web_hover_and_click
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def web_hover_and_click(self, elementToHover_locator, elementToClick_locator, elementToHover_selected_num=1, elementToClick_selected_num=1):
"""Hover and click ,复合操作命令
elementToHover_locator: 同Selenium2Library里的locator, 指定hover目标元素-hover的区域位置.
elementToClick_locator: 同Selenium2Library里的locator, 指定hover后出现的目标元素-要点击的元素位置.
elementToHover_selected_num: 指定hover目标元素序号.
elementToClick_selected_num: 指定hover后出现的目标元素序号.
[不输入(默认值): 点击第一个元素];
[=0 : 点击最后一个元素];
[=x(>0): 点击第x个元素].
一般使用方法:
| Web Hover And Click | xpath=//div[3]/ul/li[1] | xpath=//div[3]/ul/li[1]/span[2]/a[3] |
| Web Hover And Click | ${elementToHover_locator} | ${elementToClick_locator} |
带seleted_num使用方法:
注意 locators的xpath表达方式以及seleted_num的设定,需要保持hover元素和点击元素的一致性
| Web Hover And Click | xpath=//div/div[3]/ul/li | xpath=//span[2]/a[3] | 2 | 2 |
| Web Hover And Click | ${elementToHover_locators} | ${elementToHover_locators} | 0 | 0 |
(在运行该KW会将浏览器窗口移到你看不到的地方,以后也别想看到,屏幕截图是好的,哈哈~~)
"""
#self._current_browser().set_window_size(100, 100)#设置窗口大小
self._current_browser().set_window_position(-10000, -10000)#设置窗口位置将窗口移出桌面。。。
self._info("Hover '%s' and click '%s'" % (elementToHover_locator, elementToClick_locator))
elementToHover = self._get_selected_element(elementToHover_locator, elementToHover_selected_num)
elementToClick = self._get_selected_element(elementToClick_locator, elementToClick_selected_num)
if elementToHover is None:
raise AssertionError("ERROR: Element %s not found." % (elementToHover_locator))
if elementToClick is None:
raise AssertionError("ERROR: Element %s not found." % (elementToClick_locator))
actions = ActionChains(self._current_browser())
actions.move_to_element(elementToHover)
#actions.move_to_element(elementToClick)
actions.click(elementToClick)
actions.perform()
self._current_browser().set_window_position(0, 0)#移回来了。。
示例15: test_t_511_links_transporting_a_boat
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element [as 别名]
def test_t_511_links_transporting_a_boat(self, windows_handles=None):
print '\n' + "Verifying: Links -> Transporting a Boat"
driver = self.driver
driver.maximize_window()
actions = ActionChains(driver)
menu = driver.find_element_by_xpath("//*[contains(text(), 'Links')]")
actions.move_to_element(menu).perform()
time.sleep(3)
contactIDLink = driver.find_element_by_xpath("//*[contains(text(), 'Transporting a Boat')]")
actions.move_to_element(contactIDLink).click().perform()
driver.switch_to.window(driver.window_handles[-1])
transABoatPageVerification = WebDriverWait(driver, 20).until(EC.presence_of_element_located(
(By.XPATH, "//*[contains(text(), 'Pacific States Marine Fisheries Commission')]")))
transBoatTitle = driver.title
assert transBoatTitle == 'Pacific States Marine Fisheries Commission', 'The Transporting a Boat page link did not load properly'