Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
666 views
in Technique[技术] by (71.8m points)

javascript - Puppeteer can't click div in gmail

I'm trying to click the 3 dots on gmail here: 1

And then click the 'mark all as read': 2

I click on the 3 dots fine.

However I cannot click on the mark all as read.

I can select it when i inspect element by: div[class="J-M aX0 aYO jQjAxd"] > div[class="SK AX"] > div[class="J-N"]:nth-child(1)

However i cannot click it

I have tried:

  • A normal .click the selector

  • .focus then .click the selector

  • moving my mouse over the selector then clicking where the mouse is

  • hard waits before clicking

  • different selectors

  • etc

              var selector = 'span[class="asa bjy"]'
              await cursor.move(selector)
              await cursor.click()
              await page.waitForNavigation({ waitUntil: "networkidle2" })`
    

This prior part is fine (uses ghost-cursor), it clicks on the 3 dots. But the following does not work

            await page.waitFor(1500)

            var selector = 'div[class="J-M aX0 aYO jQjAxd"] > div[class="SK AX"] > div[class="J-N"]:nth-child(1)'
            await page.waitForSelector(selector);
            await page.click(selector);

Any advice welcome. Please let me know if i need to add more detail.

question from:https://stackoverflow.com/questions/65939575/puppeteer-cant-click-div-in-gmail

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

not sure what you are trying to do, but reading/writing emails via puppeteer is a lot slower than using Gmails public API: https://developers.google.com/gmail/api. Using the API will make sure your code runs consistently, and won't break next time google updates some misc UI element in their HTML.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...