Thursday 26 October 2023

Using one XPath for multiple login page

I had a scenario in multi tenant azure environment, where the login page were different for DEV, UAT, STG environment. Instead of creating separate login page for each environment, I had to optimise by having one login handler.

People can have different approach to handle Login Page.

I implemented a solution where irrespective of login page, we should have a single XPath for Username, Password and Signin button.

The solution is very simple to implement of having multiple "or" conditions in the XPath of username field, password field and signing button.

Ultimately, the appearance of the Username field is important. 

Let's take an example of different login page of outlook.com and yahoo.com username field, I used below XPath

//input[@id='login-username' or @id='i0116']

Please refer below screenshot.







-Pankaj Dhapola
Let's Think on it