puppeteer: how to wait until an element is visible?

前端 未结 6 1710
粉色の甜心
粉色の甜心 2020-12-01 05:22

I would like to know if I can tell puppeteer to wait until an element is displayed.

const inputValidate = await page.$(         


        
6条回答
  •  旧时难觅i
    2020-12-01 05:46

    If you want to ensure the element is actually visible, you have to use

    page.waitForSelector('#myId', {visible: true})
    

    Otherwise you are just looking for the element in the DOM and not checking for visibility.

提交回复
热议问题