The Talent500 Blog
15 Basic Interview Questions Every Selenium Automation Tester Must Know 1

15 Basic Interview Questions Every Selenium Automation Tester Must Know

Given the world’s reliance on web-based applications, there is an equal need for software quality assurance. QA can be done manually, but if one is to save time, money and errors, it’s better to take the path of automation. This is the niche that Selenium dominates because it’s free, open source, and easy to use. With the ongoing need for QA, the job market is often rife with the demand for professionals with Selenium testing skill sets. Senior Selenium testers in India earn an average pay of Rs.8.93 lakh as per PayScale and so, climbing up the rungs in this domain is well worth the effort. In fact, an early career test automation engineer earns above Rs.6 lakh per annum on average, with tips, bonuses and overtime pay added.

To enjoy a hefty compensation, however, it is crucial to start off your career at a reputed organisation. This demands that you stand head and shoulders above the competition by nailing the basic Selenium interview questions that are normally asked. To be prepared and put your best foot forward, go through these 15 interview prep questions for a Selenium automation tester with 1 to 3 years of experience.

1. Selenium is open source and free. Suggest 5 more reasons to use it and comment upon its demerits.

The pros of Selenium include:

  • Compatibility with all major browsers like Firefox, Chrom(ium), IE, Opera and Safari
  • Support for multiple programming languages like Java, C#, Ruby, Python, PHP, Perl, JavaScript, R, Haskell, and Objective-C
  • A large community in its official user group
  • Ongoing repository developments
  • Parallel test executions with the help of Selenium Grid

The demerits of Selenium include:

  • Requires 3rd party tools to be a comprehensive automation testing solution
  • Additional software required for mobile app testing
  • No professional tech support
  • Demands proficiency in one coding language

2. What does the Selenium suite comprise?

The Selenium tool suite consists of:

  • Selenium IDE: Integrated Development Environment is a browser extension used to record and playback tests.
  • Selenium WebDriver: A web framework used for automated web application testing to verify proper performance. It comprises opensource APIs, driver, library, and framework.
  • Selenium RC: Selenium Remote Control is a framework that allows an automation tester to automate UI tests using any programming language. It is now officially deprecated.
  • Selenium Grid: A Selenium feature that allows for parallel tests against different browsers on several machines.

3. What is Selenium 2.0, Selenium 3.0, and Selenium 4.0?

Selenium 2.0 is a single tool comprising of RC (Selenium 1) and WebDriver. Selenium 3.0 is an improvement on Selenium 2.0, with bug fixes. Selenium 4.0 is being developed with a focus on W3C standardisation. It is currently in an alpha release.

4. What is XPath and Dynamic XPath in Selenium?

XPath is an XML path and is used by testers to navigate through the XML structure of a document to find an element based on its XML path expression. XPath may be used on XML and HTML documents. There are 2 types of XPath: absolute and relative.

Dynamic XPath or custom XPath is a way to find an element uniquely and, here, the expressions Contains, Ancestor and Sibling can be used.

5. List out ways in which you can find an element in Selenium

WebDriver supports the following locators:

  • ID
  • ClassName
  • Name
  • TagName
  • LinkText
  • PartialLinkText
  • XPath
  • CSS Selector

6. What is meant by POM and what are its advantages?

POM stands for Page Object Model and is a design pattern used in Selenium to build an Object Repository for web UI elements. Here, each webpage has a corresponding Page Class and the different page elements are defined to be variables on the class.

POM optimises code, makes it maintainable, readable, reusable, and easier to grasp. Moreover, the test cases and Object Repository are independent, allowing for different integrations and testing.

7. Explain what Page Factory is in reference to POM.

Page Factory is a class in Selenium that allows testers to implement POM in an optimised way, wherein the @FindBy annotation is used to declare web elements and locate them. The idea of separating Test Methods and Page Object Repository is followed. @FindBy can have tagName, xpath, partialLinkText, name, linkText, className, id, and css for attributes. initElements() is used to initialise web elements that @FindBy locates.

8. Can you distinguish between single slash and double slash in relation to XPath?

An absolute XPath is created with a single slash “/” and a relative XPath is created with a double slash “//”. Testers use a single slash to start selection from the root node and cover the entire path till the element. Testers use a double slash to start selection from any point in the document, find a unique parent node and locate the element from there.

9. Name 4 exceptions in Selenium WebDriver.

  • NoSuchElementException: Thrown when an element is not present on the web page.
  • NoSuchWindowException: Thrown when the window target to be switched to is invalid.
  • TimeoutException: Thrown when command completion exceeds the wait time.
  • StaleElementReferenceException: Thrown when the element is detached or deleted from the current DOM.

10. How can Selenium handle alerts?

Selenium has 3 types of alerts: simple, prompt and confirmation. Alert handling can be done with:

Selenium has 3 types of alerts: simple, prompt and confirmation. Alert handling can be done with:

  • Void dismiss(): Corresponds to the ‘Cancel’ button being clicked
  • Void accept(): Corresponds to the ‘OK’ button being clicked
  • String getText(): Captures and returns the alert message
  • Void sendKeys(String stringToSend): Sends the data string to the alert box

11. How can Selenium handle multiple windows?

Selenium can handle multiple windows with the following methods:

  • get.windowhandle(): To obtain the current window’s window handle
  • get.windowhandles(): To obtain the window handles of every window opened
  • set: To set the window handles in the form of a string
  • switch to: To toggle between windows
  • action: To perform an action on the window

12. Distinguish between assert and verify commands

Both commands are used for validating an application. However, in case of:

  • Assert: The test will terminate if the condition is false and not go to the next step
  • Verify: Execution of the test won’t stop if a condition turns out false

13. Distinguish between driver.close() and driver.quit() commands

Testers use:

  • driver.close(): Closes the browser window in focus, the current instance of the WebDriver
  • diver.quit(): Closes all browser windows, all instances of the WebDriver

14. When would you use ID, XPath, Name and CSS Selector locators?

  • ID: When the elements on web page all have unique IDs
  • Name: When the elements on the web page have unique names
  • CSS Selector: For quick identification and top performance when elements do not have unique names and IDs.
  • XPath: To access almost any element, when there is no other easier or preferred locator

15. How would you perform database testing using Selenium?

Though Selenium WebDriver is limited to browser-based testing of applications, some amount of database testing can be carried out with the help of JDBC and ODBC.

These 15 questions cover the basic elements of Selenium, while also probing some tricky concepts. They will surely serve as a primer to more advanced questions and help you answer interview questions just like an industry expert would.

If you are on the lookout for a great Selenium automation tester job, sign up with Talent500. Our dynamic skill assessments and machine learning algorithms redefine job search for India’s best software engineers, seamlessly matching skill sets to the needs of Fortune 500 companies looking for the top 10% of talent. This way you’ll assure yourself of a promising career path – one that’s tried and tested!

Sharanya Rao

Sharanya Rao

Content Marketing Strategist at Talent500. Innately curious about things in general. A strategic planner who loves to make lives easier. An optimist holding on dearly to a glass half-full.

Add comment