Selenium Interview Questions

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 question that has been asked to you. our quick refresher guide on selenium should help you to brushup all the key points while preparing for the interview.

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

Selenium 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 needs to pay extra for technical support. It also supports cross Browser compatibility with Firefox, Chrome, Internet Explorer, Safari, etc., and has platform compatibility with Windows, Mac OS, Linux, etc. You also have the flexibility to work with your choice of programming language.
Selenium interview questions,selenium interview questions and answers,selenium interview questions for experienced,selenium interview questions for 3 years experience,selenium interview questions for 2 years experience,selenium basics interview questions,selenium basic interview questions and answers

Selenium 3 is the latest stable version and Selenium 4 is in alpha release, Selenium-4-alpha-4.
Updated November 24, 2021: Latest Version of Selenium 4 has been released on October 13, 2021.
check out the latest version here
Ruby, Java, Python, C#, and JavaScript
You may want to mention the languages(s), you are comfortable with. The 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
This is one of the most popular Selenium interview questions, to check the awareness about Selenium.
The answer should be – No, Selenium supports the 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 the Selenium tool alone mobile applications cannot be tested, with the 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 browsers.
– Selenium doesn’t have a built-in object repository.
– Selenium is 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 are 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 reasons, and it ensures that the 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 the “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, the 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 the 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 the web applications. 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 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 the 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 the 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 conditions 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) is a design pattern for creating an Object Repository for web UI elements. Each web page in the application is required to have its own corresponding page class. The page class is thus responsible for finding the WebElements in that page and then performing 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 that 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 the 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 keypress 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.
The listener is defined as an interface that modifies the default TestNG’s behaviour. 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.