Selenium Interview Question Part – 2

July 14, 2016

Here is the second list of questions frequently asked in Selenium Interviews.

If you have any question, query or feedback in below questions, Feel free to write us at

Ques 1 : What are two different methods to launch a Browser in Selenium WebDriver?

There are two methods to launch a browser:

  • get(url)
Ques 2: How to send ENTER/TAB key in Selenium WebDriver?
Ques 3: List down methods for Alert Handling?

Following are the frequently used methods within an alert.

  • Accept an alert.
  • Reject an alert.
  • Get Message from an alert.
Ques4: Difference type of wait statement in Selenium WebDriver?

In Selenium WebDriver, to sync up scripts there are three types of wait:

  • PageLoadTimeout – This is the maximum time selenium waits for a page to get load successfully on a browser. If the page takes more than this time, it will throw Page not found Exception.
 Driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS);
  • Implicit Wait – this wait can be considered as element detection timeout. Once defined in a script, this wait will be set for all the WebElements on a page.
  • Selenium keeps polling to check whether that element is available to interact with or not.
  • It the maximum time, selenium code waits to interact with that Web Element, before throwing “Element not found exception”.
  • Explicit Wait – this wait can be considered as conditional wait, and is applied to a particular Web Element with a condition. There are many conditions which can be applied using explicit wait.
  • Say, for example, there is a Web Element on a page which takes more than expected time to appear on the page, so instead of increasing Implicit wait for a particular Web Element we can apply explicit wait to that element with a condition.
Ques5: Difference between Absolute and Relative xpath?

  • Absolute xpath starts from starting of the page. As in an html page, the first tag is HTML.
  • “/” is used to access an immediate child of the parent tag.
  • Example: html/body/table/tbody/tr[2]/td/input
  • Relative xpath starts from anywhere on the page.
  • “//” is used to access any child of the parent tag.
  • Syntax: //htmlTagname[@attribute=’value’]
  • Example: //input[@type=’text’] – It represents xpath of a WebElement which is represented by tagname input and has an attribute type = ‘text’.

Ques6: Write a code to get numbers of frames on a page?

  • To get the number of frames, we will call a method called findElements which will return all the frames elements in a list, and then find its size.
Ques7: How to scroll down a page using JavaScript in Selenium?

  • Scroll down operation can be performed by invoking JavaScript:
Ques8: How to get the colour of a text or a link text?

Ques9: How to get the width of a textbox?

Ques10: How to take Screenshot in Selenium WebDriver?

  • To take a screenshot in Selenium there is a method called getScreenshotAs() from a class called TakesScreenshot.
Ques11: What is the basic syntax of xpath?

Basic syntax of relative xpath:

//Html Tagname[@attribute=’value’]

Ques12: What are different methods in xpath?

  • Methods  in xpath – contains(), starts-with(), following-sibling(), preceding-sibling().

Ques13: How to set the size of Browser window using selenium?

  • To set the size of a window of a Browser, method used is setSize(dim);
Ques14: How to maximise a window of a Browser using selenium?
Ques15: How to get the color of a text on a page?
Ques16: Write a code to get the status of all the checkbox on a page?

  • isSelected() – method is used to verify whether a checkbox is selected or not.
  • It’s a boolean operation returns true if selected else false.
  • To verify all the checkbox, first, get all these checkboxes (by using findElements method) in a list and then iterate this list to get the status of each checkbox.
Ques17: Write a code to wait for a particular element to be visible on a page?

  • Explicit wait can be used to apply conditional wait (here, condition is visibility of an element on a page)
Ques18: Write a code to wait for a text to change its colour?

  • To apply a conditional wait on change of property(attribute) of a WebElement explicit wait can be used.
  • Here, the attribute will be color.
Ques19: Write a code to wait for an alert to appear?

  • Waiting for an alert to appear on a page can be performed using explicit wait in Selenium WebDriver.
Ques20: How to highlight a text or an image in selenium?

  • To highlight a text or an image in Selenium, JavaScript can be injected.


Soon we will be updating next series of Interview Questions. Till then Happy Learning 🙂


About the Author


Follow Saurabh:

Leave a Comment: