xpath 在浏览器开发工具中工作,但 selenium 找不到元素

问题描述 投票:0回答:1

步骤:登录

techfetch.com
后,点击
select all
复选框,然后点击
Multiple Quick Apply
按钮。

然后:尝试选中“附加求职信”复选框。我可以使用

//*[@id="chkCL"]
xpath 在浏览器中找到元素。但是 javascript nodejs 脚本无法找到元素。

// 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'

browser dev tools xpath and ::before pesudo tags

尝试在 techfetch.com 网站的快速申请屏幕上单击“附加求职信”复选框。我是 Selenium 新手,这是我的第二个 Selenium 脚本。所以,请提供尽可能多的信息。

selenium-webdriver checkbox
1个回答
0
投票

请尝试 getWindowHandle(),看起来 AttachCoverCheckBox 元素不在同一个窗口中

© www.soinside.com 2019 - 2024. All rights reserved.