Selenium Interview Questions

selenium

1. Why do you need automation testing?

The two main reasons why we need to automate tests is to save time and money. Tests need to be repeated again and again during the development process to ensure the quality of the product. With automation testing, tests that need to repeated and can take days to complete can be done in hours.

2. What are the advantages of automation testing?

  • 1. Tests that needs repetition can be done easily and fast
  • 2. Saves time and thus money
  • 3. Vastly increases test coverage
  • 4. Human generated errors are reduced thus increasing the accuracy of testing
  • 5. It enables parallel execution
  • 6. Unattended execution

3. What is Selenium?

Selenium is automation testing tool used to automate web applications for testing purpose. In other words, Selenium is a suite of tools to automate web browsers across many platforms. Selenium has mainly two parts: Selenium WebDriver and Selenium IDE

4. What is the difference between Selenium WebDriver and Selenium IDE?

Selenium WebDriver is a collection of language specific bindings to drive a browser–the way it is meant to be driven. Selenium WebDriver is used when:

  • We need to create robust, browser-based regression automation suites and tests
  • Scale and distribute scripts across many environments

Selenium IDE is a Chrome and Firefox add-on that will do simple record-and-playback of interactions with the browser. Selenium IDE is used to

  • create quick bug reproduction scripts
  • create scripts to aid in automation-aided exploratory testing

5.Why do you prefer Selenium for Automation testing?

  • Selenium is a free and Open source tool.
  • It supports distributed testing
  • Have a huge user base and support communities
  • Can write scripts in various programming languages (JAVA, Javascript, C#, Ruby, Python etc.)
  • Cross-browser compatible (Firefox, Chrome, Safari, IE etc.)
  • Compatible with various OS platforms (Mac, Windows, Linux etc.)
  • Fresh and regular repository developments
  • Can be used to test mobile Web Applications
  • Script execution consumes less system resources

6.What are the different exceptions in Selenium WebDriver.

The most common exceptions in Selenium are:

  • TimeoutException: This exception is thrown when a command performing an operation does not complete in the stipulated time
  • NoSuchElementException: This exception is thrown when an element with given attributes is not found on the web page
  • ElementNotVisibleException: This exception is thrown when the element is present in DOM (Document Object Model), but not visible on the web page
  • StaleElementException: This exception is thrown when the element is either deleted or no longer attached to the DOM

7. What is POM (Page Object Model)? What are its advantages?

Page Object Model is a design pattern for creating an Object Repository for web UI elements. Each web page in the application is required to have it’s own corresponding page class. The page class is thus responsible for finding the WebElements in that page and then perform operations on those WebElements.

The advantages of using POM are:

  • Allows us to separate operations and flows in the UI from Verification – improves code readability
  • Since the Object Repository is independent of Test Cases, multiple tests can use the same Object Repository
  • Reusability of code

Leave a Reply

Your email address will not be published. Required fields are marked *