Hi all,
I am new bie to selenium. As part of learning i am trying to read the gmail inbx mails. Below is the html dom structure of single email of inbox mail table. I am tryuing to get the details of from-email, from-name, subject, from-date from the below highlighted html structure.
<tr class="zA yO btb" jsaction="bjyjJe:NOSeAe;pInidd:NOSeAe;" jscontroller="ZdOxDb" jsmodel="nXDxbd" id=":31" tabindex="0" aria-labelledby=":32" draggable="true"><td class="PF xY PE"></td><td id=":33" class="oZ-x3 xY" style=""><div id=":34" class="oZ-jc T-Jo J-J5-Ji " role="checkbox" aria-labelledby=":32" dir="ltr" aria-checked="false" tabindex="-1"><div class="T-Jo-auh"></div></div></td><td class="apU xY"><span id=":35" class="aXw T-KT" title="Not starred" aria-label="Not starred" role="button"><img class="T-KT-JX" src="images/cleardot.gif" alt="Not starred"></span></td><td class="WA xY" jsaction="crxiQe" jscontroller="v9XiUc"><div class="pG" data-tooltip-contained="true" data-tooltip-align="b,l" data-tooltip-delay="1500" aria-label="Not important" role="img" id=":36"><div class="T-ays-a45"><span class="aol">Click to teach Gmail this conversation is important.</span></div><div class="pH-A7 a9q"></div><div class="bnj "></div></div></td>
<td class="yX xY "><div id=":32" class="afn">Team Koinex,#KoinexUnfolds - TheFirstBlock - Source for everything Blockchain, Feb 28, The First Block is the third product from our #KoinexUnfolds campaign. Our products are based on the Delta Framework, a product-market methodology that covers t.</div><div id=":37" class="yW"><span class="bA4"><span class="yP" email="te...@koinexmail.in" name="Team Koinex" data-hovercard-id="te...@koinexmail.in">Team Koinex</span></span></div></td><td id=":38" tabindex="-1" class="xY a4W"><div class="xS" role="link"><div class="xT"><div class="y6"><span id=":3a" class="bog"><span data-thread-id="#thread-f:1626699974038366322" data-legacy-thread-id="16933301fcb1a872" data-legacy-last-message-id="16933301fcb1a872" data-legacy-last-non-draft-message-id="16933301fcb1a872">#KoinexUnfolds - TheFirstBlock - Source for everything Blockchain</span></span></div><span class="y2"><span class="Zt"> - </span>The First Block is the third product from our #KoinexUnfolds campaign. Our products are based on the Delta Framework, a product-market methodology that covers t</span></div></div></td><td class="byZ xY"></td><td class="yf xY "> </td><td class="xW xY "><span title="Thu, Feb 28, 2019, 1:49 PM" id=":3b" aria-label="Thu, Feb 28, 2019, 1:49 PM"><span>Feb 28</span></span></td><td class="bq4 xY"><ul class="bqY" id=":3c" role="toolbar"><li class="bqX brq" data-tooltip="Archive" jsaction="JqEhuc" jscontroller="pk1i4d"></li><li class="bqX bru" data-tooltip="Delete" jsaction="zM6fo" jscontroller="pmCKac"></li><li class="bqX brs" data-tooltip="Mark as unread" jsaction="XdlY1e" jscontroller="VtSflc"></li><li class="bqX brv" data-tooltip="Snooze" jsaction="u4Fnue" jscontroller="PKSrle"></li></ul></td></tr>
lease find the script code to get the same.
WebElement mailsTbl = driver.findElement(By.xpath("//table[@class='F cf zt']"));
Iterator<WebElement> mails = mailsTbl.findElements(By.tagName("tr")).iterator();
while(mails.hasNext()) {
WebElement currMail = mails.next().findElement(By.xpath("//td[@class='yX xY ']"));
WebElement unread = currMail.findElement(By.xpath("//div[@class='afn']"));
WebElement from = currMail.findElement(By.xpath("//span[@class='bA4']")).findElement(By.tagName("span"));
WebElement subject = currMail.findElement(By.xpath("//span[@class='bqe']"));
WebElement subDetails = currMail.findElement(By.xpath("//span[@class='bq3']"));
}
But herer subject and subjDetails is returned empty. Also from element is the same for every iteration. Means the first email's from-name and from-email are dislayed for every mail.
please help me where i am going wrong.
Thanks