One common error while working with Selenium

08 Jan 2020

One of the most common issues faced by software testing service companies and all others testing mobile applications with Selenium is the focusing issue. While interacting with web, the users need to find the web content. The scenario can be better understood with the help of a login example.


A login screen basically contains three text fields for Client Id, Usercode and Password. Client Id is retrieved from database 1 and password from database.

After a user enters Client Id, Usercode and Password the pointer again return back to Client Id. In this case when the user presses login button Usercode and Password get refreshed which creates issues with login. To avoid such bugs mouse pointer needs to be focussed before entering to Usercode and Password data.

Solution to the issue

The "Find Element" command serves as an effective way to solve this issue of finding a web element to be focussed within a page. To focus on multiple web elements Find Elements command can be used. One of the ways for uniquely focussing a web element within a page is by using XPATH.

Syntax for Find Element



JavascriptExecutor js = (JavascriptExecutor) driver;





WebElement login=driver.findElement(By.xpath("//input[@type='submit'and