TestGorilla helps you identify talent with the right technical skills, personality type, and behavioral attributes for your organization.
Hiring software engineers, programmers, and software testers with Selenium expertise has gotten tougher – thanks to global talent shortages and outdated hiring methods that don’t properly assess candidates' abilities.
With 1.2 million software engineering roles expected to go unfilled by 2026, getting hiring right is more important than ever. [1]
We’re here to help. This guide offers 37 Selenium tricky interview questions to help you understand just how well candidates can understand and use one of the most prominent automation testing tools on the market.
Tricky selenium interview questions are designed to assess candidates’ advanced technical experience with Selenium.
They also cover important soft skills and cognitive abilities – like problem-solving and critical thinking – in a real-world context.
The goal of these questions is to collect hard data on candidates’ skills instead of relying on bias-prone unstructured interviews.
To get the most out of these interview questions, combine them with other assessment methods – including talent assessments.
Tricky Selenium interview questions are meant to reveal which interviewees can use this automation tool at an advanced level. They aren’t meant to trick candidates. Instead, they move the interview away from practiced responses and open the floor for the interviewee to show off their skills related to Selenium automated testing.
Selenium is an open-source tool used for automating web application tests across different browsers. It lets testers write scripts that simulate user interactions to check how web applications perform and catch any issues.
The candidates you target with these questions might be applying for software engineering, programming, or any other roles needing strong automation testing skills.
Here's why complex Selenium questions are a valuable part of your hiring process.
Challenging questions give candidates a chance to show their deep understanding – how Selenium works, why it works that way, and how they can use it to solve problems and tackle tasks specific to the role.
Asking candidates complex questions doesn’t just help you assess their technical skills and abilities. It also encourages candidates to demonstrate soft skills and cognitive abilities like communication, problem-solving, and critical-thinking.
For instance, how well can a candidate explain what Selenium concepts and practices mean in a work-related context? Their explanations can clue you in to their communication skills.
If they describe the thought processes involved in navigating complex scenarios in Selenium WebDriver – like retrieving the values of specific attributes, handling multiple iframes in a window, or choosing the most effective solution to an automated testing problem – you can get more insight into their problem solving and critical thinking skills.
Traditional unstructured interview questions provide a surface-level understanding of candidates' technical and soft skills and offer little hard data about how they’ll perform in a professional context.
Complex Selenium questions, on the other hand, provide an organized, measurable, and repeatable interview process to identify top performers and predict job success. By asking candidates the same set of meaningful questions, you can easily score their responses and compare them against one another.
These structured interview questions help you reduce your interview cycles by enabling you to quickly identify the most qualified candidates.
The result? You can hire faster and smarter.
Before diving into the more advanced Selenium interview questions, our 101 Selenium interview questions resource is a helpful guide for evaluating candidates’ grasp of Selenium basics.
These questions are designed to assess candidates’ overall knowledge of the Selenium framework, the specific skills that are needed to operate the tool, and the major components of Selenium.
The below questions are designed to force candidates to think on their feet and show their high-level skills related to Selenium testing, as well as critical thinking, logic, problem-solving, and organizational skills.
Answer:
The inline frame, or iframe, is an element of HTML that puts another webpage within the parent page. There are five different ways to handle an iframe in Selenium WebDriver:
Select iframe by ID using driver.switchTo().frame(“ID of the frame”);
Use WebDriver commands to interact with the elements of the frame and perform operations
IWebElement elementInsideFrame = driver.FindElement(By.XPath("//input[@id='elementId']")); elementInsideFrame.SendKeys("Hello, frame!");
Locate iframe by tagName: driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));
Locate iframe using index: driver.switchTo().frame(0);
Switch back to the web content: switchTo().defaultContent()
Answer:
In short, the answer is no.
Interviewees should explain that Selenium is the best test automation tool for standard and responsive websites – but that the tester also needs complementary tools to handle tasks like:
Targeting RWD testing
Visual validation
Environment-based testing
Accessibility compliance
Quality analysis
Answer:
In Selenium, the Robot class is a Java-based utility class that lets the tester automate tasks that can’t be done using Selenium’s built-in methods – like simulating keyboard and mouse interactions on-screen for test automation and self-running demos.
Answer:
Answers will vary since there are various complementary tools.
Candidates should explain how tools like Applitools for visual testing and BrowserStack or Sauce Labs for cross-browser testing work well alongside Selenium.
Look for answers that show candidates know the basics of:
Connecting Selenium with BrowserStack through settings like desired capabilities
Using Applitools for visual checks right within Selenium scripts
They should also be able to describe why these tools are useful and how they improve Selenium’s functionality.
Answer:
Skilled candidates should list the following four commands and their functions:
navigate().forward(): This command navigates the user to the next web page based on browser history
navigate().back(): This command navigates the user to the previous web page based on browser history
navigate().to(): This command navigates the user to a new web page based on a specific URL while maintaining the browser history and cookies
navigate().refresh(): This command allows the user to perform a page refresh and is the most commonly used across test automation for page refreshing
Answer:
The driver.close() command is used to close the current tab/window of the browser, which is controlled by the Selenium WebDriver.
The driver.quit() command closes all browser windows and ends the Selenium
WebDriver session.
Answer:
driver.findElement () returns the first web element matching the provided locator strategy, while driver.findElements () returns a list of all elements that match the locator.
The former is useful when you expect a single element, like clicking a button, and the latter is used when dealing with multiple elements, like a list of search results.
Answer:
The Page Object Model (POM) is a design pattern where you create separate classes to represent each web page in your application.
These classes encapsulate the page's elements and interactions, making tests more readable and maintainable – and reducing the duplication of code. It separates the test logic from the UI structure, which simplifies maintenance since changes in UI can be localized to the corresponding page class.
Answer:
TestNG is a popular Java framework that permits the user to write automation tests for testing applications and packages. NG stands for Next Generation, and it's commonly used in Selenium to boost the efficiency and organization of test cases.
Candidates should include how the tester can use features like grouping, parallel testing, and reporting with TestNG.
Answer:
Page Factory is a class in Selenium WebDriver that makes it easier to create Page Objects. Specifically, it makes the automation code more readable by distinguishing the initialization of web elements from the test code.
In Page Factory, testers also use the @FindBy annotation to locate and declare web elements using different locators.
Answer:
It’s the process of parameterizing test scripts (or executing the same test multiple times with different parameters) to automate the passing of data to a specific application during runtime.
Qualified candidates should explain what parameterization is and how it functions in Selenium specifically. They should also mention that this process can be conducted several times with various values.
Answer:
Selenium Grid is a component of the Selenium framework that allows you to distribute and run your tests across multiple machines, browsers, and operating systems simultaneously.
It's especially useful for running automated tests in parallel and providing better coverage across different configurations.
Tip: In the answer, look for keywords like “Hub” and "Node” and the process for registering nodes and hubs on different machines.
Answer:
You can retrieve all options in a dropdown in Selenium by using the getOptions() method of the Select class.
Candidates should be able to explain how this method retrieves all options on a Select tag and provides a list of web elements without accepting any arguments.
Answer:
The getAttribute() method provides the value of a particular HTML attribute, and the getText() method provides the visible text of a web element.
Answer:
Assertions are validations (checkpoints) to help the tester keep track of commands for an application.
They help determine whether a test case is behaving as expected by validating the automated test cases so testers can understand if the tests have passed or failed. Look for answers that touch on this definition and explain the two major assertion types:
Soft asserts help verify certain test conditions in the case even after the assert condition fails. Testers use this assert when passing one test condition is not necessary to complete subsequent tests.
Hard asserts abort test execution when the test doesn’t meet the asserted condition. Candidates should also mention that when there is an assertion error, it displays the java.lang.AssertionError exception.
When the candidate mentions hard asserts, look for answers that list the different types of Hard Assertions in Selenium:
assertNull()
assertNotNull()
assertEquals()
assertNotEquals()
assertTrue()
assertFalse()
Answer:
For dynamic elements, you must use robust locators like XPath or CSS selectors based on stable attributes or parent elements. This ensures a reliable way to locate elements even if IDs or attributes change.
Additionally, you must implement explicit waits to ensure the element is present before interacting, using ExpectedConditions to wait for specific conditions.
Answer:
XPath expressions are used to search an XML or HTML document to gather information from any part of the document, like nodes (XML elements or attributes).
Ideal answers should start by explaining what XPath is – an expression language, or syntax, for defining the elements of an XML document – then, candidates should touch on the benefits of XPath expressions.
Experienced candidates should also touch on the two types of XPath:
Absolute XPath: Direct way of finding an element
Relative XPath: Permits the tester to write from the middle of the HTML DOM without a long XPath
Answer:
findElement: This command identifies a web element in a web page
findElements: This command identifies the list of web elements in a web page
Candidates should be able to identify the subtle difference between these two commands – as well as what these different methods provide the tester.
Look for answers that explain how findElement returns the object of the first matching element of the specified locator. Candidates should also mention the exception it throws when it fails to identify the element – NoSuchElementException.
The findElements method has very limited usage, and candidates should mention that it will return value with an empty list if the element doesn’t exist on the web page.
Answer:
File upload in Selenium is an automated process that can be done easily by using the sendKeys() method.
But candidates should also be able to explain the two additional methods using the AutoIT tool and Robot Class.
Here are the methods:
1. Upload files using sendKeys: This method is an inbuilt file upload feature with the following syntax:
WebElement upload_file = driver.findElement(By.xpath("//input[@id='file_up']"));
upload_file.sendKeys("C:/Users/Sonali/Desktop/upload.png");
2. Upload files using AutoIT: This is an open-source automation tool specifically for Windows operating systems. It’s in BASIC scripting language for automating the Microsoft Windows user interface and provides individual executions, supports simple playback scripting, easily debugs code, and is user-friendly.
3. Upload files with Robot Class: As we saw earlier, Robots help execute tasks, like keyboard and mouse functions, but they also have advantages for file upload. Candidates should explain how a Robot class can input events, like key pressing and releasing for copying, pasting, and entering.
Answer:
Browser cookies are small data blocks stored by websites and placed on a user’s computer. They are typically placed on a device used to access websites and handle tasks like session management, tracking, and personalization.
Look for answers that provide in-depth knowledge of the key ways to manage browser cookies:
1. Retrieving cookies: Candidates should start by explaining the get_cookies() method, which returns a set of dictionaries that each represent a cookie with attributes like name, value, domain, path, expiry, and secure flag.
2. Adding cookies: The add_cookie() method takes a cookie dictionary as its parameter, focusing on the most important attributes – name and value.
3. Deleting cookies: To delete cookies, candidates should mention the delete_cookie() method, which takes the cookie’s name as a parameter.
4. Handling individual cookies: Candidates should know and explain how Selenium WebDriver allows the tester to manage cookies individually. For example, the tester can grab a specific cookie using its name and change its attributes with the first two methods mentioned above.
5. Handling expiry time: Ideal answers include an understanding of expiry time and Selenium’s ability to set a cookie’s expiry time with the attribute in the cookie dictionary.
Managing browser cookies is important for these scenarios:
Logging in
Maintaining a session’s status
Performing cookie-based function tests
Executing various automation tasks
Answer:
WebDriver Waits ensure synchronization between the test automation code and the application's behavior. They prevent race conditions by waiting for certain conditions to be met before performing actions. This minimizes the chances of test failures due to elements not being ready for interaction, leading to more stable and reliable tests.
Answer:
FluentWait is an advanced version of WebDriverWait, allowing custom polling intervals and ignoring specific exceptions. It's useful for handling scenarios where elements might appear/disappear over time.
To implement it, you must create a FluentWait instance, set up its conditions and polling intervals, and then use it to wait for an expected condition to be satisfied.
Answer:
getWindowHandle() returns the unique handle of the currently focused window or tab.
getWindowHandles() returns a set of all open window handles. This is especially handy when dealing with multiple windows or tabs, allowing easy switching between them.
Answer:
To perform drag-and-drop, you must use the Actions class. You call clickAndHold() on the source element, then moveToElement() to the target element, and finally release the mouse using release(). This simulates the drag-and-drop action effectively.
Answer:
Answers will vary depending on testing frameworks and tools candidates use.
Candidates should explain approaches like saving and reusing session cookies to maintain a logged-in state across multiple test cases – which are especially useful when running parallel tests.
Look for answers that mention retrieving cookies with getCookies(), storing them, and reapplying them in subsequent tests with addCookie().
They might also mention handling session tokens or using tools like Selenium Grid to ensure session continuity across different nodes, showing an understanding of both browser state management and test efficiency.
Answer:
To simulate keyboard events, you must use the Actions class. You use the sendKeys() method on a web element to input text or trigger keyboard shortcuts. This is useful for scenarios like filling in forms or interacting with keyboard-based functionality.
Answer:
DesiredCapabilities are a class used to configure properties and settings for browser sessions in Selenium WebDriver. They allow you to specify various browser-specific settings such as version, platform, and browser capabilities. This is particularly helpful when you need to run tests on specific browser configurations.
Answer:
While both methods navigate to a URL, driver.get() waits for the page to fully load before proceeding. In contrast, driver.navigate().to() navigates to the URL but doesn't wait for the page to load completely. This can be useful when you want to continue testing without waiting for the page load to finish.
Answer:
To simulate mouse hover, you must use the Actions class and call the moveToElement() method on the element you want to hover over. This mimics a real user moving the mouse cursor over an element, triggering any associated hover actions.
Answer:
Dynamic waits are essential for handling unpredictable delays. You must use explicit waits with ExpectedConditions to wait for specific conditions before proceeding. This ensures that the test waits only as long as necessary and avoids unnecessarily long wait times.
Answer:
When a JavaScript alert appears, you must switch to it using driver.switchTo().alert(). Then, you use accept() or dismiss() methods to handle the alert, depending on whether you need to accept or dismiss it. This allows seamless interaction with JavaScript alerts.
Answer:
To execute JavaScript code, use the executeScript() method provided by WebDriver. This method allows you to run custom JavaScript code within the context of the current page. It's useful for scenarios where direct manipulation of the DOM is required.
Answer:
You must use a testing framework like TestNG or JUnit to configure parallel test execution. These frameworks allow you to specify thread counts or annotations to run tests concurrently.
Additionally, Selenium Grid provides a built-in solution for parallel test execution across various browsers and devices.
Answer:
The Chromium DevTools Protocol Integration is a significant enhancement introduced in Selenium 4 that allows testers and developers to interact with the Chrome DevTools Protocol directly from their Selenium scripts. This integration enables advanced debugging, profiling, and analysis of web pages during automated testing.
Answer:
While Selenium WebDriver is a powerful tool, it can’t automate non-browser activities such as desktop applications or mobile apps. Additionally, it may struggle with CAPTCHA and reCAPTCHA challenges due to their dynamic nature. Lastly, browser updates or changes can sometimes break the compatibility of test scripts, necessitating updates.
Answer:
Relative Locators, also known as "Friendly Locators", are a new feature introduced in Selenium 4. They provide an intuitive and human-readable way to locate web elements based on their relationships with other elements on the page.
These relationships include locating elements that are above, below, to the left, to the right, or adjacent to a reference element. Relative Locators simplify complex element identification scenarios and make test scripts more readable.
Example: WebElement element = driver.findElement (RelativeLocator.with (By.id ("elementA")).below (By.id ("elementA")));
Answer:
In Selenium 4, the interaction with iframes has been enhanced to provide a more intuitive and convenient way to switch between frames. The new approach allows you to switch directly to iframes using their web elements or using the index of the iframe. This simplifies the process of interacting with content within iframes
Before we used switchTo ().frame (), but now in Selenium 4, we have various other methods, like:
By Web Element
By Index
By Name, or ID
(driver.switchTo().frame("iframeNameOrId");)
Tricky Selenium interview questions are an important part of the hiring process – but they don’t help you understand each candidate fully. You must use these alongside other assessment methods.
To get big-picture views of your candidates, use assessments at the top of the hiring funnel. By assessing your candidates as soon as they apply, you can quickly see who has the skills you need.
You can do this easily with TestGorilla – a talent discovery platform with a massive test library.
Our test Library includes a Selenium With Python test (preview below), which assesses a candidate’s ability to automate browser activities using Selenium with the Python programming language. Similar to the interview questions above, this test uses real-world scenarios based on common applications and problems that Selenium users face.
We have tons of other tests, too – including technical skills, soft and cognitive abilities, personality and culture tests, and more.
And with our platform, you can mix up to five tests to create a perfect assessment for your Selenium specialist candidates. You can even customize tests with your own custom questions. This means you can include some of the interview questions from above in your tests!
Alternatively, you can save these questions for interviews with your top candidates.
Our system scores candidates’ assessments for you — so shortlisting top-scoring candidates for your tricky interview is easy.
Why do we recommend this approach? Well, using a mix of tests and other assessment methods – like interviews – is an important part of a holistic hiring process. This process also helps you look at multiple “measures” or skills areas – not just Selenium expertise. This gives you a clearer overview of each candidate’s technical abilities, soft skills, personalities, and more – so you can pick the most skilled and suitable person for your role.
💼 Guess what? Our customers can post remote roles on our job board, so if you’re hiring remotely, consider attracting Selenium experts there.
The trickiest questions force candidates to dive deep into specific automation methods, assertions, system processes, and best practices – everything they’ll need to succeed as Selenium specialists.
To get the most out of the tricky questions listed above, use them as part of a holistic testing process. TestGorilla is the perfect platform to help you do this.
To learn more, sign up for TestGorilla’s Free plan or request a free 45-minute live demo.
Source:
1. (2017, November 2). The U.S. Science and Engineering Workforce: Recent, Current, and Projected Employment, Wages, and Unemployment. Congressional Research Service. Retrieved August 31, 2023, from https://crsreports.congress.gov/product/pdf/R/R43061/11
Why not try TestGorilla for free, and see what happens when you put skills first.
Biweekly updates. No spam. Unsubscribe any time.
Our screening tests identify the best candidates and make your hiring decisions faster, easier, and bias-free.
This handbook provides actionable insights, use cases, data, and tools to help you implement skills-based hiring for optimal success
A comprehensive guide packed with detailed strategies, timelines, and best practices — to help you build a seamless onboarding plan.
A comprehensive guide with in-depth comparisons, key features, and pricing details to help you choose the best talent assessment platform.
This in-depth guide includes tools, metrics, and a step-by-step plan for tracking and boosting your recruitment ROI.
A step-by-step blueprint that will help you maximize the benefits of skills-based hiring from faster time-to-hire to improved employee retention.
With our onboarding email templates, you'll reduce first-day jitters, boost confidence, and create a seamless experience for your new hires.
Get all the essentials of HR in one place! This cheat sheet covers KPIs, roles, talent acquisition, compliance, performance management, and more to boost your HR expertise.
Onboarding employees can be a challenge. This checklist provides detailed best practices broken down by days, weeks, and months after joining.
Track all the critical calculations that contribute to your recruitment process and find out how to optimize them with this cheat sheet.