亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 Puppeteer 中單擊帶有 data-elementid 的按鈕?

如何在 Puppeteer 中單擊帶有 data-elementid 的按鈕?

白豬掌柜的 2023-07-14 16:48:31
如何在 Puppeteer 中單擊帶有 data-elementid 的按鈕?網站上有這樣的:<button class="M-r MB-r j3 Mn-cy" tabindex="0" type="button" data-elementid="searchButton">我正在嘗試單擊按鈕:const selector = '#searchButton';await page.waitForSelector(selector);await page.click(selector);我嘗試等待 10 秒以確保頁面已完全加載。收到錯誤:TimeoutError: waiting for selector `#searchButton`有什么想法嗎?
查看完整描述

1 回答

?
慕容3067478

TA貢獻1773條經驗 獲得超3個贊

問題似乎出在選擇器上。

這:

const selector = '#searchButton';

在 html 中翻譯成這樣:

id="searchButton"

但你正在尋找data-elementid="searchButton"屬性。

試試這個:

const selector = '[data-elementid="searchButton"]';


查看完整回答
反對 回復 2023-07-14
  • 1 回答
  • 0 關注
  • 136 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號