selenium - 尝试使用 Selenium 自动登录亚马逊但收到 JavaScript 错误
问题描述
我正在尝试使用 Selenium 自动登录亚马逊,但出现 JavaScript 错误。下面的代码给出了下面的错误,如何解决这个问题?
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
driver = webdriver.Chrome()
action = ActionChains(driver)
time.sleep(1)
driver.get('http://www.amazon.in')
time.sleep(3)
firstLevelMenu = driver.find_element_by_xpath('//*[@id="nav-link-accountList"]/span[2]')
driver.implicitly_wait(3)
action.move_to_element(firstLevelMenu).perform()
time.sleep(3)
出现错误"action.move_to_element(firstLevelMenu).perform()"
selenium.common.exceptions.JavascriptException: Message: javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite. (Session info: chrome=86.0.4240.75)**
解决方案
这是打开该帐户选项卡的方法。
driver.get('http://www.amazon.in')
try:
firstLevelMenu =WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#nav-link-accountList")))
action = ActionChains(driver)
action.move_to_element(firstLevelMenu).perform()
except Exception as e:
print(e)
进口
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
推荐阅读
- mpi - 使用 GNU Parallel 等和 PBS 队列系统在多个节点上作为单个作业运行超过 2 个或更多 MPI 代码
- eclipse - 在没有 SonarQube 的 Eclipse 中清除 SonarLint 注释发生
- r - 为现有 R 项目创建 git 存储库 - “致命:找不到远程参考主控”错误
- javascript - 如何为 amcharts4 饼图创建自定义图例
- javascript - React 和 typescript ReactRouterProps 问题
- go - 比赛条件。无法弄清楚为什么
- javascript - 错误:在 VUEJS(ESLINT)中找不到模块“babel-code-frame”
- arrays - 将两个组合数组合并为一个数组
- javascript - 如何检测使用 javascript 添加/删除的伪元素
- php - Wordpres 税务查询或单个分类