Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMAIL - Unable to open the latest email and click on one of the link #11

Open
samathan opened this issue Nov 26, 2019 · 4 comments
Open

Comments

@samathan
Copy link

samathan commented Nov 26, 2019

Hi,

I am trying to open the latest email in Gmail and click on one of the click. But I am unable to.
Here are steps using Puppeteer ,

  1. Login into GMAIL, ---- Successful
    2.Search for the "Unread email with the text"- Successful
  2. Now using xPath trying to click on the latest email but failing,
    Below is the code
    await page.waitForXPath('//[@Class="zA zE"]');
    const [emails] = await page.$x('//
    [@Class="zA zE"]');
    if(emails)
    {
    await Promise.all([
    await page.waitForNavigation(),
    emails.click()
    ])
    }
    it says TypeError: Cannot read property 'click' of undefined

Could anyone please help me with this.

@graphee-gabriel
Copy link

Hello @samathan , quick question, how did you manage to login to gmail, last time i checked google blocks automated browsers from login in to their services, so i'm really curious :-) !

@samathan
Copy link
Author

Hi @graphee-gabriel, you are right, even I have seen 2 types of blocking issues with 2 different gmail accounts.
With one gmail account its captcha, but just deleting the node modules and did npm install again resolved the captcha issue.

With another gmail account it says "You are trying to sign in from a browser or app that doesn't allow us to keep your account secure".
I couldn't resolve this issue.

@graphee-gabriel
Copy link

graphee-gabriel commented Dec 19, 2019

Yes exactly mine is the second one.
My guess is that you can't use google services through browser automation, as they want you to use their APIs.
Therefore I'll dig in what i can do with the available APIs.
A heavier alternative if you really want to do UI automation is to use global screen reader/automator services such as UIPath.

@thaihunghung
Copy link

use
await pageGmail.keyboard.press("ArrowDown");

    const activeElement = await pageGmail.evaluate(() => {
        const focusedElement = document.activeElement; 
        if (focusedElement) {
            focusedElement.click(); 
            return focusedElement.innerText; 
        }
        return null;
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants