Testing is among the most important bits in SDLC (Software Development Life Cycle) as it identifies bugs and checks whether an application is working as expected. In the past, software testers used manual testing techniques. However, manual testing is time-consuming and also comes with other various challenges. Selenium was created to automate software testing. Selenium is now a market leader, and most software testers are already using it. If you want to get a job as a software tester, arming yourself with the common selenium interview questions will give you a competitive edge over other job seekers. The following are the Selenium Interview Questions and Answers you are likely to come across:
What is Automation Testing?
In simple terms, automation testing is the process of automating the process of writing and executing software tests using an Automated Test Suite or without manual involvement. Automation testing allows testers to use a separate tool to execute test tasks repeatedly.
What are the benefits of Automation Testing?
Saves time and money. Software testing can be expensive if you have to pay manual testers. Automated testing can be cheaper in the long run. Promotes code reusability. You can set up the tests once, and the execution is done repeatedly. Reduces human-generated errors, improving accuracy. Perfect for large-scale applications. Testing a small app can be simple with manual testing. However, as the app scales, an automated testing kit will come in handy as the app scales.
What is Selenium?
Selenium is an open-source and free web UI-based automation testing suite that Jason Huggins developed in 2004. The presence of a strong community has made Selenium one of the most popular automated software testing suites. Selenium Suite is supported on various browsers and platforms.
What are the different forms of Selenium?
Selenium is not just a testing tool but a suite of several tools. The following are the different forms of Selenium;
Selenium Integrated Development Environment (IDE) Selenium WebDriver Selenium Remote Control (RC) Selenium Grid
Which programming languages are supported by Selenium?
Python Java C-Sharp JavaScript Ruby PHP Perl
Which test types are supported by Selenium?
Regression Testing Functional Testing
What is Selenium WebDriver?
Selenium WebDriver is tasked with communicating with web browsers. This tool also relies on its native compatibility to automate various tasks.
What is Selenium IDE?
Selenium IDE is a Firefox plugin that acts as a recording and playback tool. This plugin was created as a solution for speeding up the creation of automation scripts.
What is a Selenium Grid?
This tool allows users to distribute test execution to multiple environments and platforms concurrently.
What is selenium RC (Remote Control)?
RC is a tool that allows someone to create test scripts in the programming language they desire. This tool also allows users to execute test scripts within a large spectrum of browsers.
What is meant by Selenese?
Selenium IDE has a language called Selenese that is used to write Selenium commands. These commands help Selenium understand what operations or actions to perform.
What are the types of Selenese?
Actions. These are commands that manipulate the application’s state. ‘Type this box’ and ‘click this link’ are examples of Actions. Accessors. These commands the application’s state and store results in variables. Assertions. These are commands that enable the tester to verify the application’s state.
What are the approaches to locating an element in Selenium?
ID ClassName Name TagName LinkText PartialLinkText Xpath CSS Selector DOM
What is an XPath?
An XPath locates a web element based on its Extensible Markup Language path. An XML stores organizes and transports arbitrary data.
“/” and “//” in XPath. What is the difference?
“/” or the single slash creates an XPath with an absolute path. Thus, the XPath is created to start selection from the start node/ document node. “//” or the double slash is used to create an XPath with a relative path. Thus, the XPath created starts selection from anywhere within the document.
What is an Absolute XPath?
An Absolute XPath starts with a single slash “/”. Such a path has a complete path from the root to the element we want to identify.
Differentiate between findElement() and findElements()
findElements(): uses the given locating mechanism to find all the elements on the current page and returns a list of all the web elements. findElement(): finds the first element within the current page using the given locating mechanism and returns just a single web element.
Which types of Annotations which are used in Selenium?
BeforeSuite BeforeTest BeforeClass BeforeMethod Test Case AfterMethod AfterClass AfterTest AfterSuite
What are Assertions in Selenium?
Assertions determine whether the application is working as expected. If the assertions fail, the test case fails, and the execution stops.
What are Assert and Verify commands?
Assert: if the assert conditions are true, the program will continue to execute the next test step. However, if the condition is false, execution stops, and no other tests will be done. Verify: Test execution will go on irrespective of whether the verified condition is true or false.
What is the same-origin policy, and how does Selenium handle it?
The same-origin policy can be described as a security mechanism that restricts how a script or document that is loaded by a specific origin interacts with a resource from another origin. Such an approach helps isolate malicious scripts. Selenium uses a proxy injection method to implement the same-origin policy. In this setup, the Selenium Server will act as a client-configured HTTP proxy between the application under test and the browser. This proxy injection will mask AUT through a fictional URL.
What is the pause feature in Selenium IDE?
Pause is a wait Selenium IDE command that delays the execution of automated testing for a specified time. The wait is denoted in milliseconds, meaning you should input 3000 if you want to wait for 3 seconds.
Why do Selenium IDE tests fail?
Asynchronous websites. Selenium tests are created in a certain order. However, some websites are based on asynchronous architecture, and sometimes, responses are not in order. Timeouts. Selenium can fail while waiting for a component to load. Such errors can be handled using “waits”. Bugs. Selenium is always being improved. However, you may encounter some bugs occasionally, which may cause the tests to fail. Small changes to the source code. If a change to a locator is checked, all the tests directed to this locator can fail.
What is TestNG, and what are some of its features?
TestNG is a Test Automation Framework inspired by JUnit and NUnit. NG, Next Generation, is an open-source and free tool. These are some of the TestNG features;
Has different types of Assertions. Allows users to run tests in parallel. You can make tests dependent on each other using ‘dependsOnMethods’ and ‘dependsOnGroups’ attributes. Carries out data-driven tests. You can group various tests.
What is the difference between Implicit Wait and Explicit Wait?
Implicit Wait tells the WebDriver to wait for a certain period before throwing an exception. The default value is 0, and once the time is set, the WebDriver will wait until it lapses to throw an exception. Explicit Wait tells the WebDriver to wait for certain conditions or ExpectedConditions before throwing an “ElementNotVisibleException” exception. Explicit Wait is an ‘intelligent’ wait that applies only to specified elements.
What is an Object Repository?
An Object Repository is a collection of key-value pairs in an automated GUI test script that lightens the burden of test script maintenance. The key in such a case is a logical name identifying the objects as well as values that come with unique properties that identify objects on a screen. It is also a central location where all the data is stored and managed.
What different exceptions can you come across in a Selenium web driver?
An exception is an unprecedented or unusual event that may occur during program or software application execution. It can also be described as a runtime error of an unexpected event or result which disrupts or influences the usual program flow. These are the major exceptions in Selenium Web Driver;
NoSuchWindowException. The WebDriver is trying to switch to an invalid (unavailable) window. NoSuchElementException. Occurs when an element is unreachable. NoAlertPresentException. This exception occurs when you try to switch to no presented alert. TimeoutException. The specific command did not finish within the specified time. ElementNotVisibleException. ElementNotSelectableException. Such an exception occurs when an element is disabled (cannot be selected or clicked) despite being available on the DOM. SessionNotFoundException. The WebDriver, in this case, is acting immediately after closing the browser.
List out different types of Locators
Id Name className tagName linkText partialLinkText CSS selector XPath
What are Breakpoints and Start Points?
Start Points show where the execution of a code should start. Start Points can be used to run a test script from the middle of the code or the Breakpoint. Breakpoints are used to stop code execution. A breakpoint is used to verify that your code is working as expected.
Wrapping Up
Above are some of the Selenium interview questions you will likely encounter in your next test automation engineering job interview. Ensure you have the necessary skills before applying for a test automation engineer role.