Here are the top 31 sample Selenium interview questions and their answers. These sample questions are framed by experts from Intellipaat who train for Selenium Training to give you an idea of the type of questions asked in interviews. We have taken full care to give accurate answers to all the questions. Do comment your thoughts!
Automation testing is the process of automating the manual testing of the application under test (AUT) or the system under test (SUT). It includes the involvement of testing tools that help us create test scripts, which can be used repeatedly without any human intervention.
Selenium RC is called Selenium 2.0, and the integration of Selenium RC and WebDriver as a single tool has formed Selenium 3.0.
Learn for free ! Subscribe to our youtube Channel.
Selenium uses locators to find and match the elements of a web page that it needs to interact with. There are different types of locators to identify various web elements on a web page:
For testing web-based applications, Selenium can be used.
The test types supported by Selenium are:
Learn more about Selenium from this insightful blog on How would you test Web Applications using Selenium?
While DOM is the recognized standard way for navigating through an HTML element tree, XPath is the navigation tool 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 that is very much similar to HTML tags. Both being markup languages and falling under the same umbrella, XPath can be used to locate HTML elements.
The fundamental concept behind locating elements using XPath is traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.
Selenium should be used for test automation as it:
Yes, Selenium has a few limitations:
Enroll today in our Selenium Course to know more about Selenium!
An object repository allows testers to accumulate web elements of the application under test (AUT), along with their locator values, in one or more centralized locations as restricted to hard-coding them within the test scripts.
In Java, a special form of syntactic metadata can be added to Java source code, which is known as ‘annotations’. Variables, parameters, packages, methods, and classes are annotated. Some of the JUnit annotations are:
JUnit annotations linked with Selenium are:
Selenium is more widely used than QTP since:
You can find more on Selenium by visiting our Selenium Community!
Four parameters that need to be passed in Selenium are:
The ‘Same-origin Policy’ is introduced for security reasons.
To avoid this same-origin policy, the proxy injection method is used. In the proxy injection mode, Selenium Server tricks the browser to be a real HTTP URL, i.e., it acts as a client-configured HTTP proxy, which sits between the browser and the application under test (AUT) and then masks the AUT under a fictional URL.
A data-driven framework in Selenium is an approach of separating a ‘dataset’ from the actual ‘test case’ (code). This framework is completely dependent on the input test data. The test data is inserted from the external sources, such as from an Excel file, a CSV file, or from any database. It also allows us to easily control how much data needs to be tested. We can easily increase the number of test parameters by adding more username and password fields to the Excel file (or other sources).
A keyword-driven framework is an extension to the data-driven testing framework in the sense that it not only isolates the test data from the scripts but also keeps the particular section of the code belonging to the test script in an external data file. These sets of code are known as keywords, and hence the framework is so named. Keywords are self-guiding and work based on what actions need to be performed on the application.
If the file is on the same machine or in a mapped network drive, it is really straightforward: We have to just type the ‘path’ of the file in the FileUpload control.
driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
Learn more about Selenium from this informative Selenium Tutorial!
Selenese is a set of commands in Selenium used for running a test.
Three types of Selenese are as follows:
To insert a breakpoint:
The following syntax can be used to launch the browser corresponding to the system’s operating system:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new InternetExplorerDriver();
WebDriver driver = new ChromeDriver();
There are two types of waits available in WebDriver:
Explicit waits are instantiated for a particular instance only, whereas implicit waits are not.
An iframe (an acronym for ‘inline frame’) is used to insert another document within the current HTML document.
Selecting iframe by ID:
driver.switchTo().frame(“ID of the frame“);
Locating iframe using the tagName:
Locating iframe using index:
driver.switchTo().frame(“name of the frame”);
Go through the Selenium Course in London to get a clear understanding of Selenium!
SettingPriority in TestNG:
Test Execution Sequence:
Different types of frameworks are as follows:
Learn more about Selenium in this Selenium training in New York to get ahead in your career!
Breakpoints: Breakpoints are used to stall the execution of the test. The execution will stop whenever a breakpoint is implemented, and this will help us check whether the code is working properly or not.
Start points: Start points are the points from where the execution should begin. Start points can be used when we want to run the test script from the middle of the code or after a breakpoint.
While working with Selenium, we need session handling. This is because, during test execution, Selenium WebDriver has to interact with the browser all the time to execute the given commands. It is also possible that, before the current execution completes, someone else starts the execution of another script in the same machine and in the same type of browser. So to avoid such a situation, we need session handling.
The types of Listeners in TestNG are:
Selenium solely supports web application testing. It does not support the testing of Windows-based applications or mobile applications. To handle Windows-based popups, third-party intervention is required. AutoIt and Robot Class are examples of third-party tools that we can use alongside Selenium to handle Windows-based popups.
Interested in learning Selenium? Check out our Selenium Training in Sydney!
For the database testing in Selenium WebDriver, we need the JDBC (Java Database Connectivity) API. It allows us to execute SQL statements.
We can use isElementPresent (string locator) to find an object in Selenium. It takes a locator as the argument and, if found, returns a Boolean.
Become a master of Selenium by taking up this online Selenium Course in Toronto!
This is a quality peace of work. Thank you for the good effort.
With this Interview Q and A. I come to know some technical tips on Selenium. It will be very helpful for my interview preparation.
Thank you so much for valuable information.
I like the questionaire. It summarises well what questions and key points that both employers and emplyees need to know. Thanks for sharing that. @roger_uk
Your email address will not be published. Required fields are marked *
Solve : * 4 + 7 =