How to get a name and text in the email from Gmail and set in list using xpath?

I’m trying to get a Name and text in the email from Gmail and set in list using xpath in Chrome to save in a excel.
To confirm the XPath value, I collect the xPah (using XPath Helper) and show in the Chrome screen and show me the correct value. But in run-time the Xpath is return NULL.
To get the Name in Gmail I’m using Xpath: //[@id=":8q"]/div[2]/div[2]/p[1]
To get the text in Gmail I’m using xPath: //

If I change the variable to String instead of LIST, when I run the workfusion return me the error:
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:. Please, someone have an idea for me to get the text gmail information of many emails?

Hi @miriam.lara

The IDs are dynamical and change every time you open Gmail, so relative Xpaths will not work in some cases.
But you can use absolute XPaths in this case, although it can be hard to build them. I used such Xpath to get the subject of the first email, for example: /html/body/div[7]/div[3]/div/div[2]/div/div[2]/div/div/div/div/div[2]/div/div/div/div/div[6]/div/div/div[2]/div/table/tbody/tr[1]/td[5]/div[2]/span/span

Hi @ashapkina,
Thank you a lot for your response.
I’m very frustrated to get the email content in GMAIl and YAHOO mail. And I gave up to get the content email.
Now I’m using the xPath to get only the subject of the first email (using //[@id=“mail-app-component”]/div[2]/div[2]/div[1]/header/div[2]/span/span) and email name (using //[@id=“mail-app-component”]/div[2]/div[2]/div[2]/ul/li[1]/div/header/div[2]/div[1]/span/span/span/span).
But when I receive a reply email with the same subject it isn’t work. :frowning:
But any way, I’m reading and delete the email to keep in the fist email.
Thanks for your support.