提问人:Srinivas 提问时间:11/17/2023 最后编辑:Srinivas 更新时间:11/17/2023 访问量:26
XPath 在浏览器 devtools 中有效,但 Selenium 找不到元素
xpath works in browser devtools but selenium cannot find element
问:
步骤:登录后,单击复选框,然后单击按钮。techfetch.com
select all
Multiple Quick Apply
然后:尝试选中“附上求职信”复选框。我可以使用 xpath 在浏览器中找到元素。但是javascript nodejs脚本无法找到元素。//*[@id="chkCL"]
// url https://www.techfetch.com/js/js_applyemail.aspx?quickapply=true
let attachCoverCheckBox = await driver.findElement(By.xpath('//*[@id="chkCL"]'))
Process exited with code 1
Uncaught NoSuchElementError NoSuchElementError: Unable to locate element: //*[@id="chkCL"]
at throwDecodedError (file:///C:/work/selenium/apply-jobs/node_modules/selenium-webdriver/lib/error.js:524:15)
at parseHttpResponse (file:///C:/work/selenium/apply-jobs/node_modules/selenium-webdriver/lib/http.js:601:13)
at execute (file:///C:/work/selenium/apply-jobs/node_modules/selenium-webdriver/lib/http.js:529:28)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
No debugger available, can not send 'variables'
浏览器开发工具 XPath 和 ::Before
Pesudo 标签
尝试单击 techfetch.com 网站快速申请屏幕上的“附加求职信”复选框。我是 Selenium 的新手,这是我的第二个 Selenium 脚本。因此,请尽可能多地提供信息。
答:
-1赞
Gulzhas Mailybayeva
11/17/2023
#1
请尝试 getWindowHandle(),看起来 attachCoverCheckBox 元素不在同一窗口中
评论