Selenium interview questions part 2/Selenium Interview Questions and Answers for Freshers & Experienced

How Selenium grid hub keeps in touch with RC slave machine?

At predefined time selenium grid hub keeps polling all RC slaves to make sure it is available for testing. The deciding parameter is called “remoteControlPollingIntervalSeconds” and is defined in “grid_configuration.yml”file.

Other than the default port 4444 how you can run Selenium Server?

You can run Selenium server on java-jar selenium-server.jar-port other than its default port.

Can we use Selenium RC to drive tests on two different browsers on one operating system without Selenium Grid?

Yes, it is possible when you are not using JAVA testing framework. Instead of using Java testing framework if you are using java client driver of selenium then TestNG allows you to do this. By using “parallel=test” attribute you can set tests to be executed in parallel and can define two different tests, each using different browser.

What is selenium RC (Remote Control)?

Selenium IDE have limitations in terms of browser support and language support. By using Selenium RC limitation can be diminished.

>> On different platforms and different web browser for automating web application selenium RC is used with languages like Java, C#, Perl, Python
>> Selenium RC is a java based and using any language it can interact with the web application
>> Using server you can bypass the restriction and run your automation script running against any web application

How can you retrive the message in an alert box ?

You can use the storeAlert command which will fetch the message of the alert pop up and store it in a variable.

What are core extension ?

If you want to “extend” the defualt functionality provided by Selenium Function Library , you can create a Core Extension. They are also called “User Extension”. You can even download ready-made Core Extension created by other Selenium enthusiats.

What if you have written your own element locator and how would you test it?

To test the locator one can use “Find Button” of Selenium IDE, as you click on it, you would see on screen an element being highlighted provided your element locator is right or or else an error message will be displayed

From Selenium IDE how you can execute a single line?

From Selenium IDE single line command can be executed in two ways

<> Select “Execute this command” by right clicking on the command in Selenium IDE
<> Press “X” key on the keyboard after selecting the command in Selenium IDE

Using Selenium IDE is it possible to get data from a particular html table cell ?

You can use the “storeTable” command

Example store text from cell 0,2 from an html table


Css=#table 0.2


What is the difference between Page Object Model (POM) and Page Factory?

Page Object is a class that represents a web page and hold the functionality and members.
Page Factory is a way to initialize the web elements you want to interact with within the page object when you create an instance of it.

What is Page Factory?

We have seen that ‘Page Object Model’ is a way of representing an application in a test framework. For every ‘page’ in the application, we create a Page Object to reference the ‘page’ whereas a ‘Page Factory’ is one way of implementing the ‘Page Object Model’.

List some scenarios which we cannot automate using Selenium WebDriver?

1. Bitmap comparison is not possible using Selenium WebDriver
2. Automating Captcha is not possible using Selenium WebDriver
3. We can not read bar code using Selenium WebDriver

How to handle Ajax calls in Selenium WebDriver?

Handling AJAX calls is one of the common issues when using Selenium WebDriver. We wouldn’t know when the AJAX call would get completed and the page has been updated. In this post, we see how to handle AJAX calls using Selenium.

AJAX stands for Asynchronous JavaScript and XML. AJAX allows the web page to retrieve small amounts of data from the server without reloading the entire page. AJAX sends HTTP requests from the client to server and then process the server’s response without reloading the entire page. To handle AJAX controls, wait commands may not work. It’s just because the actual page is not going to refresh.

Can You Use Selenium For Rest API Testing Or Web Services Testing?

Simple answer for this is Selenium is not a tool for API Testing. It automates web browsers. Rest API & Web Services contains no UI. So we cannot automate using Selenium.

Is it possible to automate the captcha using Selenium?

No, It’s not possible to automate captcha and bar code reader.

How do you read test data from excels?

Test data can efficiently be read from excel using JXL or POI API. POI API has many advantages than JXL.

Explain in Selenium IDE how can you debug the tests?

> Insert a break point from the location from where you want to execute test step by step
Run the test case
> At the given break point execution will be paused
> To continue with the next statement click on the blue button
> Click on the “Run” button to continue executing all the commands at a time

Explain how you can insert a break point in Selenium IDE ?

In Selenium IDE to insert a break point

1. Select “Toggle break point” by right click on the command in Selenium IDE
2. Press “B” on the keyboard and select the command in Selenium IDE
3. Multiple break points can be set in Selenium IDE

From your test script how you can create html test report?

To create html test report there are three ways

TestNG: Using inbuilt default.html to get the HTML report. Also XLST reports from ANT, Selenium, TestNG combination
JUnit: With the help of ANT
Using our own customized reports using XSL jar for converting XML content to HTML

What is the fundamental difference between XPath and CSS selectors?

The fundamental difference between XPath and CSS selector is – using XPaths we can traverse up in the document i.e. we can move to parent elements. Whereas using the CSS selector, we can only move downwards in the document.

How can you prepare customized html report using TestNG in hybrid framework ?

There are three ways

<> Junit: With the help of ANT
<> TestNG: Using inbuilt default.html to get the HTML report. Also XST reports from ANT, Selenium, Testng combinations
<> Using our own customized reports using XSL jar for converting XML content to HTML

Explain how to iterate through options in test script?

To iterate through options in test script you can loop features of the programming language, for example to type different test data in a text box you can use “for” loop in Java

// test data collection in an array

String[ ] testData = { “test1” , “test2” , “test3” } ;

// iterate through each test data

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

Explain how you can use recovery scenario with Selenium?

Recovery scenarios depends upon the programming language you use. If you are using Java then you can use exception handling to overcome same.
By using “Try Catch Block” within your Selenium WebDriver Java tests

What is the command that is used in order to display the values of a variable into the output console or log?

In order to display a constant string, command can be used is echo <constant string>
If order to display the value of a variable you can use command like echo ${variable name>>

Which web driver implementation is fastest?

HTMLUnit Driver implementation is fastest, HTMLUnitDriver does not execute tests on browser but plain http request, which is far quick than launching a browser and executing tests.

How will you use Selenium to upload a file ?

You can use “type”command to type in a file input box of upload file. Then, you have to use “Robot” class in JAVA to make file upload work.

Using web driver how you can store a value which is text box?

You can use following command to store a value which is text box using web driver

driver.findElement(“your Textbox”)).sendKeys(“your keyword”);

How can we move to the nth-child element using the CSS selector?

Using :nth-child(n) in the CSS locator, we can move to the nth child element e.g. div:nth-child(2) will locate 2nd div element of its parent.

Mention what are the capabilities of Selenium WebDriver or Selenium 2.0 ?

WebDriver should be used when requiring improvement support for

. Handling multiple frames, pop ups , multiple browser windows and alerts
. Page navigation and drag & drop
. Ajax based UI elements
. Multi browser testing including improved functionality for browser not well supported by Selenium 1.0

Explain how Selenium Grid works?

Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launch the browser and run the test. With entire test suite, it allows for running tests in parallel.

What is Object Repository ?

An object repository is an essential entity in any UI automations 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.

What is the difference between single and double slash in Xpath?

Single slash is used to create Xpath with an absolute path i.e. the XPath would be created to start selection from the start node.


Double slash is used to create Xpath with relative path i.e. the XPath would be created to start selection from anywhere within the document


Explain what is Datadriven framework and Keyword driven?

Datadriven framework: In this framework, the test data is separated and kept outside the Test Scripts, while Test Case logic resides in Test Scripts. Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script. Variables are used for both for input values and for verification values.

Keyworddriven framework: The keyword driven frameworks requires the development of data tables and keywords, independent of the test automation. In a keyword driven test, the functionality of the application under test is documented in a table as well as step by step instructions for each test.

What is a pause on an exception in Selenium IDE?

The user can use this feature to handle exceptions by clicking the pause icon on the top right corner of the IDE. When the script finds an exception it pauses at that particular statement and enters a debug mode. The entire test case does not fail and hence the user can rectify the error immediately.

When do we use findElement() and findElements()?

findElement() is used to access any single element on the web page. It returns the object of the first matching element of the specified locator.

General syntax:

WebElement element = driver.findElement(;

findElements() is used to find all the elements in the current web page matching the specified locator value. All the matching elements would be fetched and stored in the list of Web elements.

General syntax:

List <WebElement> elementList = driver.findElements(;

How to set browser window size in Selenium?

The window size can be maximized, set or resized

To maximize the window


To set the window size

Dimension d = new Dimension(400,600);



The window size can be reset using JavaScriptExecutor

((JavascriptExecutor)driver).executeScript("window.resizeTo(1024, 768)");

What is the difference between driver.getWindowHandle() and driver.getWindowHandles() in Selenium WebDriver?

driver.getWindowHandle() – It returns a handle of the current page (a unique identifier)
driver.getWindowHandles() – It returns a set of handles of the all the pages available.

How to upload a file in Selenium WebDriver?

You can achieve this by using sendkeys() or Robot class method. Locate the text box and set the file path using sendkeys() and click on submit button

Locate the browse button

WebElement browse =driver.findElement("uploadfile"));

Pass the path of the file to be uploaded using sendKeys method



Before looking how to handle Stale Element Reference Exception through Page Object Model. Let’s see what is Stale Element Reference Exception first.

Stale means old, decayed, no longer fresh. Stale Element means an old element or no longer available element. Assume there is an element that is found on a web page referenced as a WebElement in WebDriver. If the DOM changes then the WebElement goes stale. If we try to interact with an element which is staled then the StaleElementReferenceException is thrown.

What are the different exceptions you have faced in Selenium WebDriver?

Some of the exceptions I have faced in my current project are

1. ElementNotVisibleException
2. StaleElementReferenceException

How to take screenshots in WebDriver?

TakeScreenshot interface can be used to take screenshots in WebDriver.

getScreenshotAs() method can be used to save the screenshot

File scrFile = ((TakeScreenshot)driver).getScreenshotAs(outputType.FILE);

How does Selenium handle Windows-based pop-ups?

Selenium was designed to handle web applications. Windows-based features are not natively supported by Selenium. However, third-party tools like AutoIT, Robot, etc can be integrated with Selenium to handle pop-ups and other Windows-based features.

Can Captcha be automated?

No, Selenium cannot automate Captcha. Well, the whole concept of Captcha is to ensure that bots and automated programs don’t access sensitive information - which is why, Selenium cannot automate it. The automation test engineer has to manually type the captcha while other fields can be filled automatically.

Explain what are the JUnits annotation linked with Selenium?

The JUnits annotation linked with Selenium are

>> @Before public void method() – It will perform the method () before each test, this method can prepare the test
>> @Test public void method() – Annotations @Test identifies that this method is a test method environment
>> @After public void method()- To execute a method before this annotation is used, test method must start with test@Before

How to retrieve CSS properties of an element?

getCssValue() method is used to retrieve CSS properties of any web element

General Syntax:

driver.findElement(“id“)).getCssValue(“name of css attribute”);



What is WebElement selenium?

WebElement in Selenium represents an HTML element. It basically represents a DOM element in a HTML document.

What are the verification points available in Selenium?

In Selenium IDE, we use Selenese Verify and Assert Commands as Verification points
In Selenium WebDriver, there is no built-in features for verification points. It totally depends on our coding style. some of the Verification points are

>> To check for page title
>> To check for certain text
>> To check for certain element (text box, button, drop down, etc.)

How do you find broken links in Selenium WebDriver?

We can detect whether the given links are broken or not by using the following process:

1. First, accumulate all the links present on a web page using the <a> anchor tag. For each <a> tag, use the attribute ‘href’ value to obtain the hyperlink
2. Send HTTP requests for each link and verify the HTTP response code
3. Based on the HTTP response code, determine if the link is valid or broken. Then, use the driver.get() method to navigate to a URL, which will respond with a status of 200 – OK (200 – OK indicates that the link is working). If we get any other status, then it indicates that the link is broken
4. Repeat the same process for all the links captured

Mention the types of navigation commands.

The following are the navigation commands provided by Selenium:

navigate().back(): It takes the user back to the previous or the last-used web page, according to the history.
navigate().forward(): It takes the user to the next web page, according to the browser history.
navigate().refresh(): It allows the user to refresh the current web page by reloading all the web elements.
navigate().to(): It takes the user to a new web page in a new window, depending on the URL specified.

R4R Team
R4R provides Selenium Freshers questions and answers (Selenium Interview Questions and Answers) .The questions on website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Selenium interview questions part 2,Selenium Freshers & Experienced Interview Questions and Answers,Selenium Objetive choice questions and answers,Selenium Multiple choice questions and answers,Selenium objective, Selenium questions , Selenium answers,Selenium MCQs questions and answers Java, C ,C++, ASP, C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Selenium fresher interview questions ,Selenium Experienced interview questions,Selenium fresher interview questions and answers ,Selenium Experienced interview questions and answers,tricky Selenium queries for interview pdf,complex Selenium for practice with answers,Selenium for practice with answers You can search job and get offer latters by studing .learn in easy ways .