How to click on first email after filter the mails

81 views
Skip to first unread message

Jagmohan Upadhyay

unread,
May 18, 2015, 11:16:44 PM5/18/15
to seleniu...@googlegroups.com
After login to gmail account, I have to search for some text(e.g. flipkart.com) and from filtered emails(it could be 20-30 mails), I need to click on first email.

I tried:

By.xpath("//td//div//span[contains(text(),'Flipkart.com')]");
it gave me: 

<span class="yP" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="yP" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>
<span class="zF" name="Flipkart.com" email="ma...@flipkartletters.com">Flipkart.com</span>

but how to click on first email after that? I am new to selenium.

Krishnan Mahadevan

unread,
May 18, 2015, 11:50:35 PM5/18/15
to seleniu...@googlegroups.com
Please DONOT use Selenium for this. You should instead try to leverage the JavaMail APIs to talk to your gmail account, read mails from it etc.,
Remember your focus here is NOT to be testing the Gmail UI but you are testing the mailing capabilities of your web application etc.,



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Technical Scribbings @ http://rationaleemotions.wordpress.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/bf09af2e-22f0-46bf-9e8a-830a1fdb7076%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kundana Devi

unread,
May 19, 2015, 11:04:15 AM5/19/15
to seleniu...@googlegroups.com
Hi Jagmohan,
What you can do is:
@FindBy(By.xpath("//td//div//span[contains(text(),'Flipkart.com')]")
List<WebElement> flipkartMails;
To click on first mail:
flipkartMails.get(0).click;

Think this will help.

Reply all
Reply to author
Forward
0 new messages