cancel
Showing results for 
Search instead for 
Did you mean: 

How to open an email on Gmail and click a link on it

bhagya_prabashw
New Contributor

How to open an email on Gmail and click a link on it

Hi All,



I'm a new user of TestComplete. I need to know the scripts for how to open an email on Gmail and click on a link on the particular email body. 



Thanks,

Bhagya.
11 REPLIES 11
TanyaYatskovska
Community Manager

RE: How to open an email on Gmail and click a link on it

Hi Bhagya,

 


You can record all your actions via TestComplete's Recording feature and get a ready test. Please read the "Recording Automated Tests - Overview" article for more information.


 


Also, I recommend that you watch TestComplete videos to learn more about the product:


---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
bhagya_prabashw
New Contributor

RE: How to open an email on Gmail and click a link on it

Hi Tanya,



Thanks for the Reply. But Record and Playback option or the script cannot identify the email as there will be always a new email. (In my test case first, I generate an email and then try to click it and open it from Gmail. The email title will be same). Please advise



Thanks,

Bhagya.
TanyaYatskovska
Community Manager

RE: How to open an email on Gmail and click a link on it

Hi Bhagya,

 


As far as I understand, you need to identify the email by its subject on the list of all emails and click it, right? You can call the Find method for this. Here is an example:


 




//JScript


var page = Sys.Browser("chrome").Page("https://mail.google.com/mail/u/0/#inbox");


var email = page.Find("contentText", "<SUBJECT>", 100);


if (email.Exists)


 email.Click();




 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
bhagya_prabashw
New Contributor

RE: How to open an email on Gmail and click a link on it

Hi Tanya,



It worked. Thank you for your help.



Bhagya.
exispam
New Contributor

RE: How to open an email on Gmail and click a link on it


Hi all,



Not sure the reply fixes the initial problem. I'm encountering the same issue as Bhagya described it first: "how to click a link stored inside a Gmail email (or do any action with a Gmail email content)?".



Tanya's answer allows us to open the Gmail email in a perfect way. Then, how to get the email content (in order to click a link, copy a string and any other testing purpose action)?

 



Gmail interface seems to associate random ID to UI items. Message panel may be named "g" or "f" or any other dynamic value. No way then to use ID for message retreiving.A



Any idea?

Thanks in advance


hhagay
Contributor

Re: RE: How to open an email on Gmail and click a link on it

This does not work with Chrom and / or Firefox.

 

Thank you

 

tristaanogre
Community Hero

Re: How to open an email on Gmail and click a link on it

Ok... curiosity question... what exactly are you testing? It seems you are spending a lot of time getting TestComplete to interact with GMAIL when you are actually testing some other sort of process that is generating the email. Specifically, it sounds like you are checking to make sure a link is generated with the proper values, etc.

So, there are two pieces to this... the process that generates the link, and the link itself which navigayes to a particular page. It seems the actual generation of the email is ancillary.

I'm assuming there is some predictability to the link generation. So, it seems to me you don't really need to check the email, you simply need to a) check in a database or some other storage to see if an email conraining the appropriate link was generated... an SQL query might solve that and check the link against expected values then b) Simply open a browser using the predicted link value and verify that the page to which you navigated is correct. Seems that mucking around with gmail, an application outside of your scope of control, seems a futile effort as all it will take is for Google to change a bit of code and, therefore, invalidate your tests.

Another suggestion : get with your programmers to create a simple email client for he sole purpose to receive the emails. Set up a local exchang server in your test environment and run your emails through that. This way, you control all the pieces and you no longer have to mess with Google.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
AlexKaras
Community Hero

Re: How to open an email on Gmail and click a link on it

The only $0.02 that I can add to the otherwise absolutely exaustive Robert's reply is that if for some reason you *really need* to check with some external mail server, you may consider some other (free) mail service with much simpler UI. Mailinator.com might be one of the possible alternatives.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
hhagay
Contributor

Re: How to open an email on Gmail and click a link on it

I agree with your comments however there are scenarios where one has to follow "user" flow in order to accomplish a case, for example; a confirmation process requires certain flow that entails an email invitation to an enrollment page which requires the user to create credentials and as a result, login.

I understand that we can manipulate the url in most cases, but by doing so we stir away from testing the true user flow and confirm the dynamic process the server uses to deliver dynamic pages....

 

my $0.04 🙂

 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors