Selenium Interview Questions and Answers

Prepare Selenium interview questions for freshers and experienced candidates. This page includes important questions, answer previews, preparation guidance, related interview topics and cached content for faster page loading.

🧪
48+ Selenium questions available

About Selenium Interview Preparation

Selenium interview questions and answers for freshers and experienced candidates, including basic concepts, advanced topics, practical examples, project discussion points and common HR preparation guidance.

For better preparation, read each question carefully, understand the concept, prepare one real example, and connect your answer with your project or work experience.

Selenium Questions List

Quick list of important Selenium interview questions. Detailed answer previews are available below.

  1. What is Automation Testing?
  2. What are the benefits of Automation Testing?
  3. Why should Selenium be selected as a test tool?
  4. What is Selenium? What are the different Selenium components?
  5. What are the testing types that can be supported by Selenium?
  6. What are the limitations of Selenium?
  7. When should I use Selenium IDE?
  8. What is Selenese?
  9. What are the different types of locators in Selenium?
  10. What is difference between assert and verify commands?
  11. What is an Xpath?
  12. What is the difference between "/" and "//" in Xpath?
  13. What is Same origin policy and how it can be handled?
  14. When should I use Selenium Grid?
  15. What do we mean by Selenium 1 and Selenium 2?
  16. Which is the latest Selenium tool?
  17. How do I launch the browser using WebDriver?
  18. What are the different types of Drivers available in WebDriver?
  19. What are the different types of waits available in WebDriver?
  20. How to type in a textbox using Selenium?
  21. How can you find if an element in displayed on the screen?
  22. How can we get a text of a web element?
  23. How to select value in a dropdown?
  24. What are the different types of navigation commands?
  25. How to click on a hyper link using linkText?
  26. How to handle frame in WebDriver?
  27. When do we use findElement() and findElements()?
  28. What is the difference between driver.close() and driver.quit command?
  29. Can Selenium handle windows based pop up?
  30. How can we handle web based pop up?

Question 1: What is Automation Testing?

Answer: Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves use to a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.

View detailed answer →

Question 2: What are the benefits of Automation Testing?

Answer: Benefits of Automation testing are: Supports execution of repeated test cases Aids in testing a large test matrix Enables parallel execution Encourages unattended execution Improves accuracy thereby reducing human generated errors Saves time and money

View detailed answer →

Question 3: Why should Selenium be selected as a test tool?

Answer: Selenium is free and open source have a large user base and helping communities have cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.) have great platform compatibility (Windows, Mac OS, Linux etc.) supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.) has fresh and regular repository developments supports distributed testing

View detailed answer →

Question 4: What is Selenium? What are the different Selenium components?

Answer: Selenium is one of the most popular automated testing suites. Selenium is designed in a way to support and encourage automation testing of functional aspects of web based applications and a wide range of browsers and platforms. Due to its existence in the open source community, it has become one of the most accepted tools amongst the testing professionals. Selenium is not just a single tool or a utility, rather a package of several testing tools and for the same reason it is referred to as a Suite. Each of these tools is designed to cater different testing and test environment requirements. The suite package constitutes of the following sets ...

View detailed answer →

Question 5: What are the testing types that can be supported by Selenium?

Answer: Selenium supports the following types of testing: Functional Testing Regression Testing

View detailed answer →

Question 6: What are the limitations of Selenium?

Answer: Following are the limitations of Selenium: Selenium supports testing of only web based applications Mobile applications cannot be tested using Selenium Captcha and Bar code readers cannot be tested using Selenium Reports can only be generated using third party tools like TestNG or Junit. As Selenium is a free tool, thus there is no ready vendor support though the user can find numerous helping communities. User is expected to possess prior programming language knowledge.

View detailed answer →

Question 7: When should I use Selenium IDE?

Answer: Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.

View detailed answer →

Question 8: What is Selenese?

Answer: Selenese is the language which is used to write test scripts in Selenium IDE.

View detailed answer →

Question 9: What are the different types of locators in Selenium?

Answer: Locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in selenium. ID ClassName Name TagName LinkText PartialLinkText Xpath CSS Selector DOM

View detailed answer →

Question 10: What is difference between assert and verify commands?

Answer: Assert: Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed. Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halts i.e. any failure during verification would not stop the execution and all the test steps would be executed.

View detailed answer →

Question 11: What is an Xpath?

Answer: xpath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, Xpath can be used to locate HTML elements. The fundamental behind locating elements using Xpath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.

View detailed answer →

Question 12: What is the difference between "/" and "//" in Xpath?

Answer: Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node. Double Slash “//” - Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.

View detailed answer →

Question 13: What is Same origin policy and how it can be handled?

Answer: The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document. Origin is a sequential combination of scheme, host and port of the URL. For example, for a URL http:// http://www.softwaretestinghelp.com/resources/, the origin is a combination of http, softwaretestinghelp.com, 80 correspondingly. Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “http://www.softwaretestinghelp.com”, then I would ...

View detailed answer →

Question 14: When should I use Selenium Grid?

Answer: Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.

View detailed answer →

Question 15: What do we mean by Selenium 1 and Selenium 2?

Answer: Selenium RC and WebDriver, in a combination are popularly known as Selenium 2. Selenium RC alone is also referred as Selenium 1.

View detailed answer →

Question 17: How do I launch the browser using WebDriver?

Answer: The following syntax can be used to launch Browser:WebDriver driver = new FirefoxDriver();WebDriver driver = new ChromeDriver();WebDriver driver = new InternetExplorerDriver();

View detailed answer →

Question 18: What are the different types of Drivers available in WebDriver?

Answer: The different drivers available in WebDriver are: Firefox Driver InternetExplorerDriver ChromeDriver SafariDriver OperaDriver AndroidDriver IPhoneDriver HtmlUnitDriver

View detailed answer →

Question 19: What are the different types of waits available in WebDriver?

Answer: There are two types of waits available in WebDriver! Implicit Wait Explicit Wait Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command. Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.

View detailed answer →

Question 20: How to type in a textbox using Selenium?

Answer: User can use sendKeys(“String to be entered”) to enter the string in the textbox. Syntax:WebElement username = drv.findElement(By.id(“Email”));// entering usernameusername.sendKeys(“sth”);

View detailed answer →

Question 21: How can you find if an element in displayed on the screen?

Answer: WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc. isDisplayed() isSelected() isEnabled() Syntax: isDisplayed():boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed(); isSelected():boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isDisplayed(); isEnabled():boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();

View detailed answer →

Question 22: How can we get a text of a web element?

Answer: Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages. Syntax:String Text = driver.findElement(By.id(“Text”)).getText();

View detailed answer →

Question 23: How to select value in a dropdown?

Answer: Value in the drop down can be selected using WebDriver’s Select class. Syntax: selectByValue:Select selectByValue = newSelect(driver.findElement(By.id(“SelectID_One”)));selectByValue.selectByValue(“greenvalue”); selectByVisibleText:Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));selectByVisibleText.selectByVisibleText(“Lime”); selectByIndex:Select selectByIndex = newSelect(driver.findElement(By.id(“SelectID_Three”)));selectByIndex.selectByIndex(2);

View detailed answer →

Question 24: What are the different types of navigation commands?

Answer: Following are the navigation commands:navigate().back() – The above command requires no parameters and takes back the user to the previous webpage in the web browser’s history. Sample code:driver.navigate().back(); navigate().forward() – This command lets the user to navigate to the next web page with reference to the browser’s history. Sample code:driver.navigate().forward(); navigate().refresh() – This command lets the user to refresh the current web page there by reloading all the web elements. Sample code:driver.navigate().refresh(); navigate().to() – This command lets the user ...

View detailed answer →

Question 25: How to click on a hyper link using linkText?

Answer: driver.findElement(By.linkText(“Google”)).click(); The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page. The above mentioned link can also be accessed by using the following command. driver.findElement(By.partialLinkText(“Goo”)).click(); The above command find the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

View detailed answer →

Question 26: How to handle frame in WebDriver?

Answer: An inline frame acronym as iframe is used to insert another document with in the current HTML document or simply a web page into a web page by enabling nesting. Select iframe by iddriver.switchTo().frame(“ID of the frame“); Locating iframe using tagNamedriver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0)); Locating iframe using index frame(index)driver.switchTo().frame(0);

View detailed answer →

Question 27: When do we use findElement() and findElements()?

Answer: findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched. Syntax: WebElement element =driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements. Syntax:List <WebElement> elementList =driver.findElements(By.xpath(“//div[@id=’example&rs...

View detailed answer →

Question 28: What is the difference between driver.close() and driver.quit command?

Answer: close(): WebDriver’s close() method closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the WebDriver. The command neither requires any parameter nor does is return any value. quit(): Unlike close() method, quit() method closes down all the windows that the program has opened. Same as close() method, the command neither requires any parameter nor does is return any value.

View detailed answer →

Question 29: Can Selenium handle windows based pop up?

Answer: Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.

View detailed answer →

Question 30: How can we handle web based pop up?

Answer: WebDriver offers the users with a very efficient way to handle these pop ups using Alert interface .There are the four methods that we would be using along with the Alert interface. void dismiss() – The accept() method clicks on the “Cancel” button as soon as the pop up window appears. void accept() – The accept() method clicks on the “Ok” button as soon as the pop up window appears. String getText() – The getText() method returns the text displayed on the alert box. void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box. Syntax:// ...

View detailed answer →

Question 31: How can we handle windows based pop up?

Answer: Selenium is an automation testing tool which supports only web application testing, that means, it doesn’t support testing of windows based applications. However Selenium alone can’t help the situation but along with some third party intervention, this problem can be overcome. There are several third party tools available for handling window based pop ups along with the selenium like AutoIT, Robot class etc.

View detailed answer →

Question 32: How to assert title of the web page?

Answer: //verify the title of the web pageassertTrue(“The title of the window is incorrect.”,driver.getTitle().equals(“Title of the page”));

View detailed answer →

Question 33: How to retrieve css properties of an element?

Answer: The values of the css properties can be retrieved using a get() method: Syntax:driver.findElement(By.id(“id“)).getCssValue(“name of css attribute”);driver.findElement(By.id(“id“)).getCssValue(“font-size”);

View detailed answer →

Question 34: What is Junit?

Answer: Junitis a unit testing framework introduced by Apache. Junit is based on Java.

View detailed answer →

Question 35: What are Junit annotations?

Answer: Following are the Junit Annotations: @Test: Annotation lets the system know that the method annotated as @Test is a test method. There can be multiple test methods in a single test script. @Before: Method annotated as @Before lets the system know that this method shall be executed every time before each of the test method. @After: Method annotated as @After lets the system know that this method shall be executed every time after each of the test method. @BeforeClass: Method annotated as @BeforeClass lets the system know that this method shall be executed once before any of the test method. @AfterClass: Method annotate...

View detailed answer →

Question 36: What is TestNG and how is it better than Junit?

Answer: Testing is an advance framework designed in a way to leverage the benefits by both the developers and testers. With the commencement of the frameworks, JUnit gained an enormous popularity across the Java applications, Java developers and Java testers with remarkably increasing the code quality. Despite being easy to use and straightforward, JUnit has its own limitations which give rise to the need of bringing TestNG into the picture. TestNG is an open source framework which is distributed under the Apache software License and is readily available for download. TestNG with WebDriver provides an efficient and effective test result format that c...

View detailed answer →

Question 37: What is a framework?

Answer: Framework is a constructive blend of various guidelines, coding standards, concepts, processes, practices, project hierarchies, modularity, reporting mechanism, test data injections etc. to pillar automation testing.

View detailed answer →

Question 38: What are the advantages of Automation framework?

Answer: Advantage of  Test Automation framework Reusability of code Maximum coverage Recovery scenario Low cost maintenance Minimal manual intervention Easy Reporting

View detailed answer →

Question 39: What are the different types of frameworks?

Answer: Below are the different types of frameworks: Module Based Testing Framework: The framework divides the entire “Application Under Test” into number of logical and isolated modules. For each module, we create a separate and independent test script. Thus, when these test scripts taken together builds a larger test script representing more than one module. Library Architecture Testing Framework: The basic fundamental behind the framework is to determine the common steps and group them into functions under a library and call those functions in the test scripts whenever required. Data Driven Testing Framework: Data Driven Test...

View detailed answer →

Question 40: Can WebDriver test Mobile applications?

Answer: WebDriver cannot test Mobile applications. WebDriver is a web based testing tool, therefore applications on the mobile browsers can be tested.

View detailed answer →

Question 42: What is Object Repository? How can we create Object Repository in Selenium?

Answer: Object Repository is a term used to refer to the collection of web elements belonging to Application Under Test (AUT) along with their locator values. Thus, whenever the element is required within the script, the locator value can be populated from the Object Repository. Object Repository is used to store locators in a centralized location instead of hard coding them within the scripts. In Selenium, objects can be stored in an excel sheet which can be populated inside the script whenever required.

View detailed answer →

Question 43: What is Selenium 2.0 ?

Answer: Web testing tools Selenium RC and WebDriver are consolidated in single tool in Selenium 2.0

View detailed answer →

Question 44: List out the test types that are supported by Selenium?

Answer: For web based application testing selenium can be used The test types can be supported are a)      Functional b)      Regression For post release validation with continuous integration automation tool could be used a)      Jenkins b)      Hudson c)       Quick Build d)      CruiseCont

View detailed answer →

Question 45: Explain the difference between single and double slash in X-path?

Answer: Single slash ‘/ ’ Single slash ( / ) start selection from the document node It allows you to create ‘absolute’ path expressions Double Slash ‘// ’ Double slash ( // ) start selection matching anywhere in the document It enables to create ‘relative’ path expressions

View detailed answer →

Question 46: List out the technical challenges with Selenium?

Answer: Technical challenges with Selenium are Selenium supports only web based applications It does not support the Bitmap comparison For any reporting related capabilities have to depend on third party tools No vendor support for tool compared to commercial tools like HP UFT As there is no object repository concept in Selenium, maintainability of objects becomes difficult

View detailed answer →

Question 47: What is the difference between type keys and type commands ?

Answer: TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing

View detailed answer →

Question 48: What is the difference between verify and assert commands?

Answer: Assert:  Assert allows to check whether an element is on the page or not. The test will stop on the step failed, if the asserted element is not available. In other words, the test will terminated at the point where check fails. Verify: Verify command will check whether the element is on the page, if it is not then the test will carry on executing.  In verification, all the commands are going to run guaranteed even if any of test fails.

View detailed answer →
Selenium interview preparation tip: Start with basic definitions, then prepare practical examples, common mistakes, project usage, scenario-based questions and HR discussion points.