selenium在前台运行是正常的,但在后台静默运行就报错:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
出错的代码是在菜单定位下,该菜单需要鼠标悬浮才能出现:
menu = browser.find_element_by_xpath('//*[@id="9903000000"]')
time.sleep(2)
ActionChains(browser).move_to_element(menu).perform()
browser.find_element_by_id('9903010400').click()
请各位大侠指导怎么弄才能保证 后台运行,谢谢。
https://www.cnblogs.com/xiaopeng4Python/p/10456462.html
解决了吗 我现在也是这个问题
Actionchains在后台运行模式下容易出错,可以用JavaScript代码来实现点击元素
browser.execute_script("document.getElementById('9903000000').click())