Most Asked Selenium Interview Questions with Answers

Selenium Interview Questions
Java Programming Masterclass for Software Developers Course for as low as ₹ 420

Here are some of the most popularly asked Selenium interview questions which are being asked during evaluation for Selenium Automation Engineers. These will certainly help you prepare one for yourself. Lets us know if it does and also help us and others by submitting a new questions that been asked to you.

refer other interview questions at automated-360
UFT Interview Questions . Test Complete Interview Questions

Selenium is a free and open source automation tool with a large user base and support communities. This itself makes a huge difference compared to other costly automation tools and one need to pay extra for technical support. It also Supports cross Browser compatibility with Firefox, Chrome, Internet Explorer, Safari etc. and have platform compatibility with Windows, Mac OS, Linux etc.. You also have flexibility to work with your choice of programming language.
Selenium 3 is the latest stable version and Selenium 4 is in alpha release, Selenium-4-alpha-4.

check out latest version here
Ruby, Java, Python, C# and JavaScript
You may want to mention the languages(s), you are comfortable with. Your rest of the interview might be related to that.
Yes, Selenium supports Firefox, IE, Safari, Opera, Chrome and Edge. Microsoft is implementing and maintaining the Microsoft Edge WebDriver,
WebDriver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox, Chrome (unlike Selenium IDE). It also enables you to use a programming language in creating your test scripts
No, Selenium supports testing of web applications only. You cannot automate desktop applications.
Limitations of Selenium are:
– Selenium support only web-based applications, it doesn’t support any windows based applications.
– Using Selenium tool alone mobile applications cannot be tested, with use of Appium we can achieve it.
– The Windows-based popup cannot be tested using Selenium alone we need to use AutoIT to handle the windows based popups.
– Selenium doesn’t have inbuilt reporting capability so JUnit/ TestNG need to use.
– Limited support for image testing.
– Selenium IDE supports only Firefox browser.
– Selenium doesn’t have built-in object repository.
– Selenium is an open source so no reliable support is available.
XPath uses path expressions to select nodes or node-sets in an XML document. These path expressions look very much like the path expressions you use with traditional computer file systems. In Selenium, it is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, XPath can be used to locate HTML elements.
Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
Double Slash “//” – 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.
The “Same Origin Policy” is introduced for security reason, and it ensures that content of your site will never be accessible by a script from another site.  As per the policy, any code loaded within the browser can only operate within that website’s domain.
To avoid “Same Origin Policy” proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL
There are certain JUnit annotations linked with Selenium.
@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
Selenium RC : Selenium Remote Control (RC) is used to write test cases in different Programming languages. In Selenium IDE, we can run the recorded scripts only in Firefox browser, whereas, in Selenium RC, we can run the recorded script in any browser like IE, Chrome, Safari, Opera etc. It interacts with browsers using Selenium RC Server
Selenium WebDriver: Selenium WebDriver is a tool used to automate testing for web application. It allows us to execute tests against different browsers like Firefox, Chrome, IE & Safari. Selenium WebDriver eliminated the use of Selenium Server thus making it to work faster than RC
findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched.
WebElement element = driver.findElements(By.xpath(“//div[@id='example']//ul//li”));

findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.
List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id='example']//ul//li”));
There are four parameters that you have to pass in Selenium are
Port Number
There are 8 different types of locators availablein Selenium
CSS Selector
CSS Selector can be used for performance and when ID & Name locators are not unique
Assert will fail the test and abort the execution of the current test case. All other test steps after that particular line of code are skipped.
Verify will log the failure but continue to execute the test case.
Soft Assert: Soft Assert collects errors during @Test Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement.
Hard Assert: Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next @Test
Implicit Waits 
Explicit Waits
Fluent Waits
The fluent wait is used to tell the web driver to wait for a condition, as well as the frequency with which we want to check the condition before throwing an “ElementNotVisibleException” exception.
WebDriverWaitis applied on a certain element with defined expected condition and time. This wait is only applied to the specified element. This wait can also throw an exception when an element is not found.
findElement() returns a single WebElement (found first) based on the locator passed as parameter. Whereas findElements() returns a list of WebElements, all satisfying the locator value passed.
Object Repository is used to store element locator values in a centralized location instead of hard coding them within the scripts. We do create a property file (.properties) to store all the element locators and these property files act as an object repository in Selenium WebDriver.
Page Object Model (POM) 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
You can scroll down a page using window.scrollBy() function. You need to use this with executeScript.
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. 
Selenium scripts use Robot class for automating the browser and desktop pop-ups.
driver.close() – Used to close the current browser having a focus
driver.quit() – Used to close all the browser instances
Using the getText() method we can fetch the text over an element.
String text = driver.findElement("elementLocator").getText();
Using deleteAllCookies() method-
.sendKeys(“sequence of characters”) – Used for passing character sequence to an input or text box element.
.pressKey(“non-text keys”) – Used for keys like control, function keys etc that are non-text.
.releaseKey(“non-text keys”) – Used in conjunction with key press event to simulate releasing a key from keyboard event.
Tooltips web elements have an attribute of type ‘title’. By fetching the value of the ‘title’ attribute we can verify the tooltip text in selenium.
Using the isDisplayed() method we can check if an element is getting displayed on a web page.
driver.findElement(By locator).isDisplayed();
JavaScript can be executed in selenium using JavaScriptExecuter.
HtmlUnitDriver is the fastest WebDriver. Unlike other drivers (FireFoxDriver, ChromeDriver, etc), the HtmlUnitDriver is non-GUI, while running no browser gets launched.
Page factory is an implementation of the Page Object Model in selenium. It provides @FindBy annotation to find web elements and PageFactory.initElements() method to initialize all web elements defined with @FindBy annotation.
Selenium grid is a tool that helps in the distributed running of test scripts across different machines having different browsers, browser versions, platforms, etc in parallel. In the selenium grid, there is a hub that is a central server managing all the distributed machines known as nodes.
TestNG is a testing framework that can be integrated with selenium or any other automation tool to provide multiple capabilities like assertions, reporting, parallel test execution, etc.
Listener is defined as interface that modifies the default TestNG’s behavior. As the name suggests Listeners “listen” to the event defined in the selenium script and behave accordingly. It is used in selenium by implementing Listeners Interface. It allows customizing TestNG reports or logs.
Below are the few TestNG listeners:
IAnnotationTransformer ,
IAnnotationTransformer2 ,
IConfigurable ,
IConfigurationListener ,
IHookable ,
IInvokedMethodListener ,
IInvokedMethodListener2 ,
IMethodInterceptor ,
ITestListener .



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.