If you’re looking for a job as a QA Engineer, Test Automation Engineer, QA Analyst, or User Acceptance Tester, part of the interview process will likely include some questions on Selenium, one of the most popular and powerful test automation tools for web applications.
The best way to prepare for Selenium interview questions is by reviewing potential questions you might be asked and practicing answering them in a mock interview setting. You can do a mock interview on your own or ask someone to play the role of the interviewer and read off questions to you. If you practice on your own, you might want to consider filming yourself so you can play back the recording and see how you did.
To help you get ready for your technical interview, here are 15 Selenium interview questions you can review, along with tips on how to answer them.
1. What are the components of Selenium Suite?
Selenium Suite consists of four components, including:
- Selenium IDE, a set of tools that include a Firefox, Chrome, and Edge plugin for building tests in the browser and exporting them.
- Selenium Remote Control, a server that controls the embedded Selenium browser. You can write tests in various programming languages to interact with it.
- Selenium Web Driver, a programming interface for Selenium. You can write tests with it in various programming languages, and it interacts natively with the web browser. Selenium Web Driver isn’t a server like Selenium Remote Control.
- Selenium Grid, a tool that allows tests to be run simultaneously on multiple devices or web browsers in parallel.
2. What is an exception test in Selenium?
You write an exception test in Selenium when you expect something to fail and throw an exception. Exception tests pass when the code throws the specific exception targeted by the test.
3. What is Selenese?
Selenese is the language used for writing test scripts in Selenium. It consists of commands that instruct the Selenium engine to perform certain tasks. There are three categories of these commands:
- Actions. These commands interact directly with the browser.
- Accessors. These commands retrieve data from the application and store them in variables.
- Assertions. These commands compare the state of an application with the expected state.
4. What is a locator in Selenium?
A locator is a command in Selenium that allows you to select, interact with, and retrieve data from elements on a web page. Selenium has many types of locators to choose from, including ID, class, Name, XPath, LinkText, and DOM.
5. What is an assertion in Selenium?
Assertions verify that the state of an application matches the intended design outcome.
For example, when a user clicks a button, you expect a modal to be visible. Types of assertions include assert, verify, and waitFor.
6. What type of tests does Selenium support?
Selenium can be used for these types of tests:
- Functional testing. All the following testing types are categories of functional testing, which test that an application functions according to the business requirements.
- Regression testing. This tests that there are no side effects or bugs when new code is introduced into the application.
- Smoke testing. This tests that the critical parts of the app function correctly.
- Sanity testing. This tests that specific parts of the app function correctly in detail after a code change.
- UI testing. This tests that the graphical elements of the application are displayed properly.
- Database testing. This tests that the data displayed in the app is in sync with the data in the database.
- Cross-browser testing. This tests that the application functions correctly and looks the same across different browsers.
7. What is a data-driven test in Selenium?
Sometimes it’s necessary to test multiple sets of input data within a field of an application. Instead of writing a custom test for each set of data, this data can be stored separately and use the same test for each set. You can store this data in Excel files, CSV files, XML files, or database tables.
8. What’s the difference between assert and verify in Selenium?
While both commands check if a condition is true or false, assert will stop the test if a condition is false and verify continues through the rest of the test case whether the condition is true or false.
9. How do you handle keyboard and mouse interactions in Selenium?
You do this with the Actions API. This API contains classes for executing keyboard and mouse events, as well as pen and scroll wheel actions.
10. What are some of the technical challenges with Selenium?
When discussing technical challenges associated with Selenium, you may want to work in some examples from your past work. You can also highlight how you dealt with these challenges, which gives the hiring team a glimpse into your critical thinking process. Here are a few ideas to get you started:
- Selenium testing only works with web-based applications and requires third-party tools to test desktop and mobile apps.
- Selenium supports capturing images or screenshots but requires third-party tools for comparing images.
- Selenium doesn’t have built-in reporting tools or test management. For these, you have to use third-party tools.
- While some tests can be written without programming knowledge using Selenium IDE, most will require you to know a programming language to customize them.
11. What types of exceptions can you expect in Selenium?
This is a question that would best be answered by referencing specific examples, a few exceptions that could be addressed include:
- TimeoutException. This is thrown when a command doesn’t complete in a specific amount of time.
- NoSuchElementException. This is thrown when an element is not found on the web page.
- ElementNotVisibleException. This is thrown when an element is not visible on the web page.
- StaleElementException. This is thrown when an element has been deleted or is no longer attached to the DOM.
12. What is XPath?
XPath is a language used to query XML documents. Since HTML is based on XML, it’s one of the languages that can locate elements on a web page with Selenium.
13. What’s the difference between driver.close() and driver.quit() in Selenium?
In Selenium, driver.close() closes the currently active window in the browser, and driver.quit() closes all browser windows and should be used carefully.
14. What navigation commands are supported by Selenium?
There are four navigation commands supported by Selenium. They are:
- navigate().back(). This command navigates to the last visited page in the browser history.
- navigate().forward(). This command navigates to the next page in the browser history.
- navigate().refresh(). This command reloads the current page.
- navigate().to(). This command navigates to a specific URL.
15. What is pause used for in Selenium IDE?
This feature is especially useful when creating new tests or debugging tests. It’ll stop the test when an exception occurs so you can examine the statement that caused the exception, correct it, and continue the test.
More interview resources
If you’re looking for additional ways to prepare for your interview, check out our complete guide to the technical interview and our advice on answering behavioral interview questions. We also have tips for the whiteboard interview. And if you’re interviewing over Zoom, check out our Zoom interview advice.
Our Career Center provides more interview support, along with job-hunting resources for resume and cover letter writing, creating a portfolio, networking, and more.If you’re looking to learn a new skill or expand on your existing knowledge, take a look through our full course catalog.