The Talent500 Blog
Most Asked Selenium Interview Questions & Answers 1

Most Asked Selenium Interview Questions & Answers

Most Asked Selenium Interview Questions & Answers

During recent times we have heard lots of news about layoffs from big companies, and many employees started looking for jobs. The first thing we should do during this time is to prepare for an interview and acquire knowledge on trending topics.

Today’s post is for all the job seekers who are going through the job hunting phase. In the current job market in almost all QA, Automation or SDET job profiles you can definitely expect questions from Selenium, that’s why we have decided to create a post on the most asked Selenium Interview questions and answers.

Before we start looking into the interview questions and answers let’s understand quickly about Selenium along with the reasons behind the popularity of the same.

The most important fact about Selenium is that it has the highest market share in any of the automation solutions available in the market for web automation, and with that fact let’s start our interview preparation with Selenium questions and answers.

What is Selenium?

Selenium is an open source umbrella project for a range of tools and libraries aimed at supporting browser automation. It provides a playback tool for authoring functional tests across most modern web browsers, without the need to learn a test scripting language. In simple words it provided an automation solution,  by using it we can write test scripts for Web Automation and perform action on webelements.

Why do we need Selenium?

Most of the programmers and developers who build website applications need to test them before releasing it in production. One of the biggest advantages of Selenium, which has made it so popular among the QAEs, is its flexibility and support to almost all the programming languages, such as Java, Python, C#, Ruby and JavaScript. Any individual who develops web programs can use Selenium to test the code and applications. As it is open source so teams don’t have to invest any huge amount for licensing to start designing Automation solutions for their projects.

In most organisations, it is the job of quality analyst (QA) engineers to test web applications by using Selenium. They are required to write scripts that can help in maximising accuracy and test coverage to make changes in the project and maintain the infrastructure of the test.

Interview Questions and Answers

  1. How to perform back, forward and refresh action in Selenium?
    Ans: navigate() can be used for these actions.
  1. driver.navigate().back()
  2. driver.navigate().forward()
  3. driver.navigate().refresh()


  1. What is the return type of findelements?

Ans: List of elements with similar property


  1. What will happen if no webelement is found for findelements?

Ans : It will return an empty list


  1. What will happen if no webelement is found for findelement?
    Ans: It will give error as :NoSuchElementException


  1. How to select value from dropdown in Selenium?

Ans: Using select class as below

Select technology = new Select(driver.findElement(By.xpath(“//select[@id=’effectTypes’]”)));



  1. What are the methods provided in Selenium to select from dropdown?

Ans: Select class can be used for dropdown, below are the methods provided by Select class

  1. selectByVisibleText()
  2. selectByValue()
  3. selectByIndex()


  1. How to fetch text from UI in Selenium?

Ans: Text can be fetch by below two ways:

  1. gettext()
  2. getAttribute(“propertyname”)
  1. How to get current url, title and page source?
  1. driver.getCurrentUrl();
  2. driver.getTitle();
  3. driver.getPageSource();


  1. How to clear text using Selenium?

Ans: clear() — method is used to clear text from the text area



  1. How to do Browser Initialization for all types of browser?

Firefox ⇒  WebDriver driver = new FirefoxDriver();

Chrome ⇒ WebDriver driver = new ChromeDriver();

Internet Explorer ⇒ WebDriver driver = new InternetExplorerDriver();

Safari Driver ⇒ WebDriver driver = new SafariDriver();


  1. What are the types of locators used to identify objects?

Ans: Below is the list of locators used to identify objects:

  1. ID
  2. Name
  3. Class Name
  4. Tag Name
  5. Link Text & Partial Link Text
  6. Link Text
  7. CSS Selector
  8. DOM (Document Object Model)
  9. XPath
  1. Difference between getwindowHandle and getwindowHandles ?


driver.getWindowHandle() returns a String of alphanumeric window handle and is mainly used to get the window handle of the current window.

driver.getWindowHandles() returns a set of window handles and is mainly used to get the window handle of all the current windows.


  1. How to handle popups and alerts in Selenium?
    Ans:  To handle pop up Alert can be used:

Alert alert = driver.switchTo().alert();


alert.accept(); //it will click on “ok”

alert.dismiss();  //it will click on “cancel”


  1. How to handle mouse and keyboard events using Selenium?

Keyboard Events Using Selenium Actions Class:

  • sendKeys(keysToSend) : sends a series of keystrokes
  • keyDown(theKey) : Sends a key press without releasing it. (example: Keys.ALT, Keys.SHIFT, or Keys.CONTROL)
  • keyUp(theKey): Performs a key release

Mouse Events Using Selenium Actions Class:

  • click ():  click on element
  • doubleClick (): Double clicks on Element
  • contextClick() : Performs a context-click (right click) 
  • clickAndHold(): Clicks at the present mouse location 
  • dragAndDrop(source, target): Invokes click-and-hold at the source location and moves to the location of the target element before releasing the mouse. source – element to grab, target – element to release
  • dragAndDropBy(source, xOffset, yOffset) : Performs click-and-hold at the source location, shifts by a given offset, then frees the mouse. xOffset – to shift horizontally, yOffset – to shift vertically
  • moveByOffset(x-offset, y-offset): Shifts the mouse from its current position (or 0,0) by the given offset. x-offset – Sets the horizontal offset (negative value – shifting the mouse to the left), y-offset – Sets the vertical offset (negative value – shifting the mouse to the up)
  • moveToElement(toElement): It shifts the mouse to the centre of the element
  • release(): Releases the depressed left mouse button at the existing mouse location


  1. What are the functions most commonly used in xpath, describe any 5?


  1. Contains
  2. Sibling
  3. Ancestor
  4. And OR
  5. Parent
  6. Starts with
  7. XPath Axes
  8. Following
  9. Preceding  



Hope the shared list of questions and answers will help the job seekers to get their dream job. One important point to remember is that there are also tools which are giving tough competition to Selenium and some of the most used automation solutions after Selenium are Cypress, Playwright and Puppeteer.

If you are looking for jobs related to Automation, QA or SDET roles then do checkout jobs with high salary at .

Sidharth Shukla

Sidharth Shukla

Currently working as a SDET. He is an Automation enabler who provides solutions that mitigates quality risk. Passionate about technical writing and contribution towards QA community.

Add comment