ActionChains 是使用 Selenium 时非常方便的方法。 它工作得很好,我唯一缺少的是如何在操作之间插入等待时间。
我将从官方的 google Selenium 文档中获取相同的示例。 https://selenium.googlecode.com/git/docs/api/py/webdriver/selenium.webdriver.common.action_chains.html
menu = driver.find_element_by_css_selector(".nav")
hidden_submenu = driver.find_element_by_css_selector(".nav #submenu1")
ActionChains(driver).move_to_element(menu).click(hidden_submenu).perform()
我正在寻找一种在两个操作之间插入等待时间的方法
ActionChains(driver).move_to_element(menu)**(..wait some seconds)**.click(hidden_submenu).perform()
谢谢!
请您参考如下方法:
我试过了,似乎有效
from selenium import webdriver
action = webdriver.ActionChains(driver)
action.pause(3)
action.perform()
driver.close()
