selenium interview questions basic level

By | July 19, 2019

In this article you will find the selenium interview questions of basic level.

1. What is an exception test in Selenium?

An exception test is an exception that you expect will be thrown inside a test class. For example, if you have written an automation test script in such way that it should throw an exception, then you can use the annotation @Test and specify which exception you are expecting by specifying it in the parameters.

Take a glance at the example below:

@Test(expectedException = NoAlertPresentException.class)

Do note the syntax, where the exception is suffixed with .class

2. Explain different types of exceptions in Selenium WebDriver.

Exceptions in Selenium are similar to exceptions in other programming languages. The most common exceptions in Selenium are:

  • StaleElementException: This exception is thrown when the element is either deleted or no longer attached to the DOM
  • 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.

3. Why and how will you use an Excel Sheet in your project?

Excel can be used as a data sheet/data provider for our tests. An excel sheet can also be used to store the data set while performing DataDriven Testing. These are the two main reasons for using Excel sheets.

When you use the excel sheet as data source, you can store the following:

  • Application URL for all environments: You can specify the URL of the environment in which you want to do the testing like: development environment or testing environment or QA environment or staging environment or production/ pre-production environment.
  • User name and password credentials of different environments: You can store the access credentials of the different applications/ environments in the excel sheet. You can store them in encoded format and whenever you want to use them, you can decode them instead of leaving it plain and unprotected.
  • Test cases to be executed: You can list down the entire set of test cases in a column and in the next column, you can specify either Yes or No which indicates if you want that particular test case to be executed or ignored.

When you use the excel sheet for DataDriven Test, you can store the data for different iterations to be performed in the tests. For example while testing a web page, the different sets of input data that needs to be passed to the test box can be stored in the excel sheet.

4. What is Page Object Model (POM)? What are the 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
  • Code reusability.
  • Since the Object Repository is independent of Test Cases, multiple tests can use the same Object Repository.

5. What is Page Factory?

Page Factory gives an optimized way to implement Page Object Model. When we say it is optimized, it refers to the fact that the memory utilization is very good and also the implementation is done in an object oriented manner.

Page Factory is used to initialize the elements of the Page Object or instantiate the Page Objects itself. Annotations for elements can also be created (and recommended) as the describing properties may not always be descriptive enough to differentiate one object from the other.

The concept of separating the Page Object Repository and Test Methods is followed here also. Instead of having to use ‘FindElements’, we use annotations like: @FindBy to find WebElement, and initElements method to initialize web elements from the Page Factory class.

@FindBy can accept tagNamepartialLinkTextnamelinkTextidcssclassName xpath as attributes.

6. What are the benefits of Automation Testing?

Benefits of Automation testing are:

  1. Supports execution of repeated test cases
  2. Aids in testing a large test matrix
  3. Enables parallel execution
  4. Encourages unattended execution
  5. Improves accuracy thereby reducing human-generated errors
  6. Saves time and money.

7. How will you find an element using Selenium?

In Selenium every object or control in a web page is referred as an elements, there are different ways to find an element in a web page they are

  • ID
  • Name
  • Tag
  • Attribute
  • CSS
  • Linktext
  • PartialLink Text
  • Xpath etc.

8. What are the testing types that can be supported by Selenium?

Selenium supports the following types of testing:

  1. Functional Testing
  2. Regression Testing

9. What are the test types that are supported by Selenium?

For web based application testing selenium can be used

The test types can be supported are

a) Functional

b) Regression

10. What are the different types of WAIT statements in Selenium WebDriver? Or the question can be framed like this: How do you achieve synchronization in WebDriver?

There are basically two types of wait statements: Implicit Wait and Explicit Wait.

Implicit wait instructs the WebDriver to wait for some time by polling the DOM. Once you have declared implicit wait, it will be available for the entire life of the WebDriver  instance. By default, the value will be 0. If you set a longer default, then the behavior will poll the DOM on a periodic basis depending on the browser/ driver implementation.

Explicit wait instructs the execution to wait for some time until some condition is achieved. Some of those conditions to be attained are:

  • elementToBeClickable
  • elementToBeSelected
  • presenceOfElementLocated

11. What is the use of JavaScriptExecutor?

JavaScriptExecutor is an interface which provides a mechanism to execute Javascript through the Selenium WebDriver. It provides “executescript” and “executeAsyncScript” methods, to run JavaScript in the context of the currently selected frame or window. An example of that is:

JavascriptExecutor js = (JavascriptExecutor) driver;


12 What are the limitations or challenges with Selenium?

Below are the technical challenges with Selenium:

  • Selenium supports only web based applications
  • It does not support the Bitmap comparison
  • For any reporting related capabilities, we have to depend on third party tools like TestNG
  • 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.

13. How to scroll down a page using JavaScript in Selenium?
We can scroll down a page by using window.scrollBy() function.


((JavascriptExecutor) driver).executeScript(“window.scrollBy(0,500)”);

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

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

Leave a Reply

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