[英]puppeteer page.click(<selector>) but could not find it
這個nodeJs在登錄后使用Puppeteer填充一個多頁面的在線網站。 其中一個頁面有一個輸入圖像可供點擊,但無法使用下面的代碼點擊它。 請說明正確點擊輸入元素的原因和方法。
//server/main.js let submitLink = await page.$('input[src="/is/images/submitBtn.gif"]') //also tried page.$('input[src=/is/images/submitBtn.gif]') await submitLink.click() Error: UnhandledPromiseRejectionWarning: Error: Node is either not visible or not an HTMLElement W20210606-15:29:14.995(10)? (STDERR) at ElementHandle._clickablePoint
<.-- here is the XPATH --> <input type="image" name="action" src="/is/images/submitBtn.gif" value="submit" tabindex="7" title="submit" alt="submit">
也試過page.click(<selector>)
無濟於事,這里是選擇器。
body > table > tbody > tr:nth-child(3) > td:nth-child(2) > table > tbody > tr > td > form > table > tbody > tr > td > table > tbody > tr:nth-child(10) > td > table > tbody > tr:nth-child(4) > td:nth-child(1) > input[type=image]
如果你試試這個怎么辦:
let submitLink = await page.$('input[src="/is/images/submitBtn.gif"]');
await page.evaluate((submit) => { submit.click(); }, submitLink);
有時elementHandle.click()
由於更復雜的仿真算法而失敗,而更簡單的 web API 工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.