简体   繁体   English

Xpath-需要Gmail邮件正文的定位器才能读取发送的邮件

[英]Xpath - Need the locator for Gmail's email body to read the message sent

Using Selenium, I am trying to read the response body of a specific email. 我正在尝试使用Selenium读取特定电子邮件的响应正文。 I have navigated to the email I desire. 我已导航至所需的电子邮件。 I just cannot seem to find a static locator to grab as the class/id is dynamically allocated. 我只是似乎找不到静态定位器,因为类/ id是动态分配的。

Anyone have a xpath that will allow me to read the text of any gmail body? 任何人都有一个xpath,可以让我阅读任何gmail正文的文本吗?

发布我自己的答案后,我发现了一个可用于定位的xpath:Gmail>收到的电子邮件>响应正文

//div[@class='ii gt ']//div[contains(text(),'**Insert your recognizable email text here**')]

It looks like message body is the element with class 'ii gt ' , so try this: 看起来消息正文是类为'ii gt '的元素,因此请尝试以下操作:

driver.findElement(By.cssSelector(".ii.gt")).getText()

But better option is to read messages via Gmail API . 但是更好的选择是通过Gmail API阅读邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM