Selenium is a suite of tools to automate web browsers across many platforms. It is a free, open-sourced application that caters to different testing requirements. This application also supports the authoring of tests without having to learn a scripting language and provides a domain-specific language to write tests in a number of popular programming languages. It also runs on most modern browsers.

Due to the many advantages, Selenium has to offer, it is one of the popular testing frameworks, and Selenium professionals are in high demand across the IT industry. To prepare for your next interview on Selenium, here are some of the frequently-asked Selenium interview questions (with answers) to help you prepare well.

Top 100 Selenium Interview Questions and Answers:

Here are to most important Selenium interview questions:

Q1. How many languages does Selenium support?

Ans. Selenium support various programming languages such as C#, Java, PHP, Ruby, Python, Perl, Javascript, etc.

Q2. What is automation testing?

Ans. Automation testing or Test Automation is a process of automating the manual process to test the application/system under test.

Automated Testing Process:

Follow given steps  for automation testing:

  1. Test Tool Selection
  2. Define Scope of Automation
  3. Planning, Design and Development
  4. Test Execution
  5. Maintenance

Automated Testing Process:

Q3. What are the different ways to find an element?

Ans. Following are the different ways to find an element:

  • ID
  • Name
  • Tag
  • Attribute
  • CSS
  • Linktext
  • PartialLink Text
  • X-path

Q4. What are the testing types supported by Selenium?

Ans. Following are the testing types supported by Selenium:

  • Functional Testing
  • Regression Testing
  • Sanity Testing
  • Smoke Testing
  • Responsive Testing
  • Cross Browser Testing
  • UI testing (black box)
  • Integration Testing

Q5. What is the difference between implicit wait and explicit wait in selenium WebDriver?

Ans. When an implicit wait is implemented in tests, if WebDriver cannot find an element in the Document Object Model (DOM), it will wait for a defined amount of time for the element to appear in the DOM.

An explicit wait can be used where synchronization is needed, for example, the page is loaded but we are still waiting for a call to complete and an element to appear.

Q6. Which is better – implicit wait or explicit wait?

Ans. Explicit waits are better than implicit wait. Unlike an implicit wait, you can write custom code or conditions for wait before proceeding further in the code.

Q7. When should I use Selenium IDE?

Ans. Selenium IDE is the simplest of all the tools in the package and should be a great tool for naïve users as it is easy to learn with minimal acquaintances in the programming language.

Q8. Explain the difference between single (/) and a double slash (//) in X-path?

Ans. Single slash (/) allows the creation of ‘absolute’ path expressions, while double slash (//) allows the creation of ‘relative’ path expressions.

Q9. What is the use of XPath?

Ans. XPath is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.



  • //: To select current node
  • Tagname: Tagname of the given node
  • @: To select attribute
  • Attribute: Attribute name of the node
  • Value: Value of the attribute

Q10. What is the difference between type keys and type commands?

Ans. Type key populates the value attribute using JavaScript whereas type commands emulate like actual user typing 

Q11. What is the difference between verify and assert commands?

Ans. Assert command allows us to check whether an element is on the page or not. Verify command checks whether the element is on the page, otherwise, the test will carry on executing.

Q12. What are heightened privilege browsers?

Ans. Heightened privileges browsers are similar to Proxy Injection, allowing websites to do something that is not commonly permitted.

Q13. Explain what is Data-driven framework and Keyword driven?

Ans. In a Data-driven framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts.

Keyword-driven frameworks require the development of data tables and keywords, independent of the test automation.

Q14. What is Object Repository?

Ans. Object repository is an essential entity in any UI automation which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

Q15. Mention 5 different exceptions you had in Selenium WebDriver?

Ans. The 5 different exceptions in Selenium WebDriver are WebDriver Exception, NoAlertPresentException, NoSuchWindowException, NoSuchElementException, TimeoutException


Q16. Which web driver implementation is the fastest?

Ans. HTMLUnit Driver implementation is the fastest

Q17. How to find more than one web element in the list?

Ans. It can be done using WebElement List. E.g.

List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

int listSize = elementList.size();

for (int i=0; i<listSize; i++)





Q18. What is the difference between driver.close() and driver.quit() command?

Ans. Close() method closes the web browser window that the user is currently working on or the browser that WebDriver is currently accessing.

Quit() method closes down all the windows that the program has opened.

Q19. In which format does the source view show your script in Selenium IDE?

Ans. XML

Q20. What is Object Repository? How can we create an Object Repository in Selenium?

Ans. 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.

In Selenium, objects can be stored in an excel sheet that can be populated inside the script whenever required.

Q21. What is Selenese and what are the types of Selenese?

Ans. Selenese is a selenium set of commands which are used for running the test.

There are three types of Selenese – 

  • Actions
  • Assertions
  • Accessors

Q22. How can you convert any Selenium IDE tests from Selenese to another language?

Ans. The format option of Selenium IDE to convert tests into another programming language

Q23. To generate pdf reports, what Java API is required?

Ans. API IText

Q24. What are the ways you can customize the TestNG report?’

Ans. You can customize TestNG report in two ways:

  • Using ITestListener Interface
  • Using IReporter Interface

Top Selenium Interview Questions and Answers:

Q25. In Selenium, what are Breakpoints and Startpoints?

Ans. A breakpoint is implemented to stop execution to check if the code is working as expected till now.

A startpoint indicates the point from where the execution should begin.

Q26. What is Selenium composed of?

Ans. Selenium is a suite of tools for automated web testing and it is composed of Selenium IDE (Integrated Development Environment), WebDriver and RC, and Grid.

Q27. Can you tell me from where the term Selenium derived?

Ans. Well, it came from a joke made by Jason Huggins (the developer of Selenium) in an email, where he mocked one of his competitors named Mercury, saying that you can cure mercury poisoning by taking selenium supplements. This is from where the other email recipients took the name and the rest is history.

Also Read – Top QA Interview Questions and Answers

Q28. Why should you use Selenium as a test tool?

Ans. Selenium is a free and open-source tool and has a large user base. It helps communities and is compatible with every browser (Chrome, Firefox, Internet Explorer, etc.). Besides, it also has great platform compatibility (Windows, Mac OS, Linux, etc.)

Q29. What is Selenese?

Ans. Selenese is the language used to write test scripts in Selenium IDE.

Q30. What is the difference between automation testing and manual testing.


Automation testing

Manual testing

Automated testing is faster and reliable than manual testing. Manual testing takes a lot of time and human efforts.
It is a more accurate method, as it uses tools and scripts.  It is not that accurate because of the human errors.
It does not allow random testing. Exploratory testing can be done in manual testing.
It is not cost effective for low volume regression It is not cost effective for high volume regression.
Programming knowledge is required in automation testing. Programming knowledge is not required in manual testing.


Q31. How do we launch a batch file in a Selenium Webdriver project?

Ans. It uses a test suite to execute a batch file and also takes an executable file to set up the process before the automation. Below code can be used to initiate the process:

Process batch = Runtime.getRuntime.exec(“path of the batch file”);


Q32. Elaborate the functioning of Selenium Grid?

Ans. Selenium Grid sends tests to the hub, which are then redirected to Selenium Webdriver. It then launches the browser and runs the test. The tests run in parallel with the entire test suite.

Q33. Can we use the Selenium grid for performance testing?

Ans. Yes, but it is not as effective as Loadrunner, which is a dedicated Performance Testing tool.

Q34. Is it possible to replace automation testing with manual testing?

Ans. Automation testing cannot fully replace manual testing as it is not possible to expect test automation to bring off all the work done by manual testing.

Q35. How will you find an element using Selenium?

Ans. Every object or control in a web page is an element in Selenium, and some of the ways to find that element in a web page include user ID, Name, Tag, Attribute, CSS, Linktext, PartialLink Text, and Xpath.

Q36. What is the Page Object Model (POM)?

Ans.POM is a design pattern responsible for creating an Object Repository for web UI elements.

Q37. What is Page Factory?

Ans. Page Factory provides an optimized way to implement Page Object Model and it has a very good memory utilization and implementation is object-oriented.

Q38. What is an XPath?

Ans. XPath is a language that helps to locate and process items in Extensible Markup Language (XML) documents. It addresses syntax based on a path through the document’s logical structure or hierarchy. XPath is used to locate a web element based on its XML path. It also stores, organizes, and transports arbitrary data.

Q39. Name different types of XPath?

Ans. There are two types of XPath:

  • Absolute XPath

Syntax: html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b

  • Relative Xpath




Q40. How do we run the selenium IDE test suite from the command line?

Ans. We can use the below command to run the test suite:


Java -jar “C:\Selenium Webdriver Questions\selenium-server-standalone-2.33.0.jar” -htmlSuite “*firefox” “” ” “C:\Selenium Webdriver Questions\SeleniumSuite.HTML”


Q41. How can we perform drag and drop action in Selenium WebDriver?

Ans. We can use the advanced user interaction API to perform drag and drop operations:


Actions act = new Actions(driver);

act.dragAndDrop(source_locator, target_locator).build().perform();

Q42. Name the Selenese command that is used to present the value of a variable?

Ans. echo()

Q43. Can Selenium handle windows based pop up?

Ans. Since it is an automation testing tool and supports only web application testing, it can’t handle windows pop up. However, third-party tools like AutoITm and Robot class are available to handle this.

Q44. How do we handle web-based pop up in Selenium?

Ans. We can use WebDriver, which provides an efficient way to handle these pop-ups using the Alert interface. Besides, there are four methods too that we can use –

void dismiss() – The accept() method clicks on the “Cancel” button when the pop-up window appears.

void accept() – The accept() method clicks on the “Ok” button when 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.


// accepting javascript alert

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


Q45. Tell me how can I take a screenshot in Selenium WebDriver?

Ans. You can do that by using the TakeScreenshot function and by using getScreenshotAs() method, you can save the screenshot.

Q46. Is it possible to enter a text without using sendKeys()?

Ans. Yes, we can enter/ send a text using JavaScriptExecutor, and we don’t need to use sendKeys() method.

Q47. What is Junit?

Ans. It is a Java-based unit testing framework introduced by Apache.

Q48. What is Object Repository?

Ans. Object Repository refers to a collection of web elements belonging to Application Under Test (AUT) along with their locator values. Object Repository is used to store locators in a centralized location.

Q49. How can we create an Object Repository in Selenium?

Ans. We can create Object Repository in an excel sheet that can be populated inside the script whenever required.

Most asked Selenium Interview Questions and Answers:

Q50. Does Selenium have any limitations?

Ans. Yes, it has.

  • It supports testing of only web-based applications
  • One cannot test mobile applications
  • Selenium can’t test Captcha and Barcode readers
  • It helps to generate reports using third-party tools like TestNG or JUnit
  • No ready vendor support
  • User must possess programming language knowledge

Q 51. Which browsers/drivers do Selenium WebDriver support?

Ans. Selenium WebDriver supports –

  • Android – Selendroid/Appium
  • Firefox – FireFoxDriver
  • Google Chrome – ChromeDriver
  • HtmlUnit (Headless browser) – HtmlUnitDriver
  • Internet Explorer – InternetExplorerDriver
  • IOS – ios-driver/Appium
  • Safari – SafariDriver

Q 52. Does Selenium Webdriver support web services testing?

Ans. Selenium WebDriver automates web applications using the browser’s native method. Therefore, it is not possible to test web services using Selenium WebDriver because they are headless.

Q 53. What is an absolute XPath?

Ans. Absolute XPath locates an element using XML expression that starts from the root node or with ‘/’. It contains the complete path of all the elements, including the root element, as well as the desired element. Absolute XPath has a significant disadvantage, which is if there is even a minor change in the UI, the entire XPath fails.

Q 54. What is a Relative XPath?

Ans. Relative XPath locates an element using XML expression, beginning from anywhere in the HTML document. This is used to create robust XPaths, which remain unaffected by changes in other UI elements.

Q 55. How do we identify a child element using XPath?

Ans. To identify a child element using XPath, we can use the below code:

Syntax: //div/a

Q 56. How to use CSS Selector for identifying web elements by class?

Ans. To identify web elements by their class, we can use .className and select elements belonging to that particular class. Apart from this, a CSS selector can locate web elements with ID, class, or name.

Q 57. How to use CSS Selector for identifying web elements by ID?

Ans. To identify web elements by ID, we can use #idValue and select elements belonging to that particular ID.

Q 58. How to use CSS Selector for identifying web elements by their attribute value?

Ans. To identify web elements by their attribute value, we can use [attribute=value] to select elements belonging to that particular attribute type.

Q 59. How can we move to nth child element using the CSS Selector?

Ans. We can use:nth-child(n) to move to the nth child element.

Q 60. Explain the difference between XPath and CSS Selector.

Ans. In XPath, we can traverse both forward and backward, while CSS selector moves forward only.

Q 61. What type of tests have you automated?

Ans. Your reply should be specific here. You should focus on how you automate test cases to do Regression testing, Smoke testing, and Sanity testing. You can also mention that you have done End to End testing, basis project, and test time estimation.

Q 62. Can we launch different browsers in Selenium WebDriver? How?

Ans. Yes, we can launch different browsers in Selenium WebDriver by creating an instance of the driver of the particular browser.

Q 63. How to check a checkBox in selenium?

Ans. One can select a checkBox the way a button is clicked.


Toggling a checkbox on/off can also be done using the click() method, and isSelected() method is used to check if the Checkbox is toggled on or off.

Q 64. Explain the difference between driver.getWindowHandle() and driver.getWindowHandles() in selenium.

Ans. driver.getWindowHandle() is a unique identifier and it returns a handle of the current page

driver.getWindowHandles() returns a set of handles of the all the available pages

Q 65. What are some possibilities of using conditions in Explicit waits?

Ans. The most common possibilities are –

elementToBeClickable(WebElement element or By locator)

stalenessOf(WebElement element)

visibilityOf(WebElement element)

visibilityOfElementLocated(By locator)

invisibilityOfElementLocated(By locator)

attributeContains(WebElement element, String attribute, String value)


titleContains(String title)

titleIs(String title)

textToBePresentInElementLocated(By, String)

Q 66. What are DesiredCapabilities in Selenium WebDriver?

Ans. DesiredCapabilities are a set of key-value pairs that help to set properties for the WebDriver. This helps to set the specific properties of browsers such as browser name, platform, and version of the browser, in the browser instances.

Q 67. What is a data-driven framework?

Ans. Data-driven is a test automation framework. It stores test data in a spread spreadsheet or table format such as MS Excel Sheets, MS Access Tables, SQL Database, XML files, etc. separated from test logic written in test script files. Data-Driven Testing enables engineers to execute tests for each set of test data values.

Q 67. What is a keyword-driven framework?

Ans.A keyword-driven framework is a type of Functional Automation Testing Framework, and it works on action word based testing. The keyword-driven framework helps to accelerate automated testing by using keywords related to the application being tested. These keywords should be included in every input to describe actions to be performed for each step and execute the test successfully.

Q 68. What is a hybrid framework?

Ans. As the name suggests, a hybrid framework is a combination of one or more frameworks and is a combination of data-driven and keyword-driven frameworks. Here the test data and test actions are kept in external files. This implements the Page Object Model Technique, Data-Driven Technique, Modular Driven Technique, Log4j Logging, TestNG Reporting, and TestNG Reporter Logs.

Q 69. What is Selenium 2.0, and how is it better than Selenium 1.0?

Ans. Selenium 1 is known as Selenium Remote Control (RC). Selenium 2.0 is a combination of Selenium 1 and WebDriver, making it superior to RC. Selenium 2 is also popularly known as Selenium WebDriver that directly sends commands to the browser instead of sending it to a server. Selenium 2.0 runs the JavaScript natively; thus there is a need to write the test once, and Selenium will test on different browsers.

Q 70. What is Selenium 3.0, and how is it better than Selenium 2.0?

Ans. There was a major WebDriver upgrade in 2016 and Selenium 3.0 incorporates that upgrade, which includes the W3C specifications for Webdriver APIs.

Q 71. How can we pass parameters to the test script using TestNG?

Ans. We can use Parameter annotation and Parameter tag in TestNG.xml to pass parameters to the test script.

New TestNG.xml –

<suite name=”newTestSuite”>

<test name=”newTest”>

<parameter name=”newParamName” value=”newParamValue”/>


<class name=”TestFile” />




Q 72. Can you explain how we can make two test methods dependent on each other using TestNG?

Ans. There is a feature in TestNG, dependency, which allows a test method to depend on other test methods. Dependency is configured by using the dependent test method separated by commas to the attribute dependsOnMethods. This is done while using test annotation on multiple test methods.

@Test(dependsOnMethods = { “preTests” })

Q 73. What is the latest Selenium WebDriver Architecture?

Ans. This block diagram will represent the latest Selenium WebDriver Architecture –

Q 74. What are the different OS/platforms supported by Selenium?

Ans. Different OS/platforms supported by Selenium include –

  • Android
  • IOS
  • Linux
  • Mac OS X
  • Windows Desktop
  • Windows Mobile

Q 75. What types of cases can be automated using Selenium?

Ans. Selenium can be used to automate the following types of cases –

  • Acceptance tests
  • Cross-browser tests
  • End-to-end test cases
  • Functional cases
  • Integration tests
  • Regression test cases
  • Responsiveness cases
  • Sanity test
  • Smoke testing

Q76. Mention the list of different types of locators?

Ans. Different types of locators are:

  • By.tagName()
  • By.className()
  • By.linkText()
  • By.xpath
  • By.cssSelector()
  • By.partialLinkText()

Q77. What is the procedure to iterate through options in the test script?

Ans.To iterate through options in the test script, you can use different test data and activate a “for” loop in the program

// test data collection in an array

String[ ] testdata = { “t1” , “t2” , “t3” } ;

// iterate through each test data

For  (string s: test data) { selenium.type ( “elementLocator”, testdata) ; }

Q78. What are the element locators that can be used to locate elements on the web page in selenium IDE?

Ans. In Selenium, there are precisely four locators that are used:

  • Html id
  • Html name
  • X-path locators
  • CSS locators

Q79. In Selenium IDE, how to generate random numbers and dates for test data?

Ans. You can generate random numbers by using Java Script in Selenium IDE




And for



javascript{new Date()}

Q80. How to retrieve the message in an alert box?

Ans. To retrieve the message in an alert box, you can use the storeAlert command that will fetch the message of the alert pop up and store it in a variable.

Q81. Mention how to obtain server-side log Selenium Server?

Ans. To obtain server-side log in Selenium Server, you can use the command:

“java –jar .jar –log selenium.log”

Q82. Mention what are the types of Listeners in TestNG?

Ans. The types of Listeners in TestNG are:

  • IConfigurationListener
  • IExecutionListener
  • IHookable
  • IAnnotationTransformer
  • IAnnotationTransformer2
  • IInvokedMethodListener
  • IInvokedMethodListener2
  • IMethodInterceptor
  • ISuiteListener
  • ITestListener
  • IConfigurable
  • IReporter

Q83. What API is required for database testing in the Selenium webdriver?

Ans. For database testing in Selenium webdriver, you require JDBC (Java Database Connectivity) API. JDBC allows you to execute the SQL statement in the database.

Q84. Explain when to use AutoIT?

Ans. Selenium is intended to automate web-based applications on various browsers. You need AutoIT to manage window GUI and non-HTML popups in the application.

Q85. How to get TagName?

Ans.To get targeted TagName, you can use below method:

WebElement ele1=driver.FindElement(By.TagName(“TagName val1”);

String tag=ele1.getTagname();


Q86. Explain the timeout commands in Implicitwait?

Ans. Following are the timeout commands in Implicitwait:

  • Days
  • Hours
  • Minutes
  • Seconds
  • Microseconds
  • Nanoseconds
  • Milliseconds

Q87. Mention how to store various windows into one object?

Ans. By using the given command, you can store various windows into one object:

Set<String> multiplewindows=driver.getwindowhandles();

Q88. Mention how to switch one frame to another frame?

Ans. To switch one frame to another frame, you can use the following command:

//Click Frames link

driver.findElement(By.xpath(“xpath val1”)).click();



driver.switchTo().defaultContent();  //Erase all switches before applying switch second time 


//Click no frames link

driver.findElement(By.xpath(“xpath val1”)).click();

Q89. Explain what is Beforeclass?

Ans. Beforeclass is an annotation in TestNG that executes before all the testcases preceded by @Test annotation.



public void methodname()




Q90. Explain what @Afterclass is?

Ans. AfterClass annotation executes after every test case when all the tests have completed execution.


public void methodname()




Q91. Explain what @Ignore is?

Ans. Ignore annotation is used to skip method execution.


public void methodname()




Q92. How do you prioritize test methods within a class?

Ans. To prioritize test methods within a class, you can use:

public class TestClass



public void testmeth1()





Q93. Mention how to pass a parameter from the XML file?

Ans. To Pass a parameter from the XML file, you can use: 

<suite name=”Naukri” >

<test name=”Learning”>


<parameter name=”browser”value=”ff”></parameter>

<class name=”packagename.classname”></class>




Q94. How to fetch data from dataprovider method?

Ans. To fetch data from the dataprovider method, you can use:

@Test(dataProvider = “dp1”)

public void f(String Naukri, String Learning)


//dp1===> dp1 is a method name where we maintain original data


Q95. How to manage data under the dataprovider method?

Ans. To manage data under the dataprovider method, you can use:


public Object[][] dp1()


String data[][]=new String[1][1];

//First Row data




Q96. Explain how to navigate to a new window from the current window?

Ans. To navigate to a new window from the current window, you can use:

driver.navigate().to(new window url) method

Q97. How to classify tooltip in selenium webdriver?

Ans. You can classify tooltip in selenium webdriver with the title tag and action class.

Write an xpath for an actual element, get the attribute of the title of that web elements


String tooltip = driver.findElement(By.xpath(“//a[text()=’Projects’]”).getAttribute(“title”);

Q98. Mention how to execute Cucumber Tests in groups using Cucumber Tags?

Ans. By indicating @RunWith(Cucumber.class) and @cucumberOptions annotations




feature=”Naukri Learning”,




You can also do something with TestNG groups attributes of @Test annotation.


Class GroupTestEx1{

@Test(groups = { “Naukri”, “Learning” })

public void testPrintMessage() {  }

@Test(groups = { “Naukri” })

public void testSalutationMessage() {  }

@Test(groups = { “Learning” })

public void testingExitMessage() {  }



<suite name = “Suite1”>

<test name = “test1”>



<include name = “Learning” />




<class name = “GroupTestExample” />




Q99. How to handle dynamic tables in Selenium?

Ans. You can handle the dynamic table using Relative xpath in Selenium.

Q100. Mention what the various types of the framework are?

Ans. Following are the various types of frameworks:

  • Data-Driven Testing Framework
  • Keyword Driven Testing Framework
  • Hybrid Testing Framework
  • Module Based Testing Framework
  • Library Architecture Testing Framework
  • Behavior Driven Development Framework

Most Common Frameworks are:

  • Hybrid Testing Framework
  • Data-Driven Testing Framework
  • Keyword Driven Testing Framework

These are some of the popular Selenium interview questions. Always be prepared to answer all types of questions — technical skills, interpersonal, leadership, or methodology. If you are someone who has recently started your career in software testing, you can always get certified in Selenium to get the requisite technical skills and experience.


If you have recently completed a professional course/certification, click here to submit a review and get FREE certification highlighter worth Rs. 500.

5.00 avg. rating (98% score) - 6 votes