2

In my application I need to send a confirmation after which an mail will arrive to my Outlook which I need to open and click on the link which is sent in the mail.

Can someone please let me know if this is possible in Selenium and Java, or is there any workaround?

2
  • 2
    Selenium is a tool that automates web browsers. The answer is no. Use a server's API to get the emails. One option is mailosaur.com.
    – pavelsaman
    Jul 29, 2021 at 11:36
  • thanks for the input
    – user50414
    Jul 29, 2021 at 11:38

4 Answers 4

1

What you are wanting to achieve in verifying an email in Outlook is considered an anti-pattern in Selenium.

A lot of people think you can and should automate everything, when there are plenty of situations where automation doesn't make sense.

Take a look at the Selenium documentation where it states:

For multiple reasons, logging into sites like Gmail and Facebook using WebDriver is not recommended. Aside from being against the usage terms for these sites (where you risk having the account shut down), it is slow and unreliable.

So, the options here are:

  • No, you can't use Selenium to automate Outlook (Desktop version) because Selenium automates apps in the browser.
  • No, you shouldn't use Selenium to automate Outlook (outlook.com web app) because it's against their terms of service, they could block you, and they could update their site, which causes you to keep updating any automation code. In this case, it's recommended to get access to an API from Outlook to make a GET request for the information you want to verify. This will be faster, less brittle, and the most appropriate way to avoid ToS violations.
0

I need to open and click on the link which is sent in the mail.

You can go to Outlook.com and grab the last email using Selenium. You would do this if there isn't something like MailTrap in place. I did this for Gmail when testing a WordPress site. The only catch is that the email sites will update without your knowledge, potentially breaking the scripts you wrote.

0

In your automation script, you can use Sikulix to automate your desktop related actions

SikuliX

0

According to software testing solutions, using Selenium + Java, if you want to automate outlook, then you will be able to do that in web version only and not on the desktop app. To automate Outlook desktop app, you will need RPA(Robotic Process Automation) which is one of the simplest tools used to automate desktop apps.

Process to click on the link in the Outlook WebApp e-mail using Selenium + Java:

  1. Search for the desired mail using the subject of the mail set as the locator and click on the same.
  2. Search for the desired link on the mail body using any locator(tagName(a)) and click on the same.
  3. Verify that the link has been opened by checking the URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.