TestGorilla LogoTestGorilla Logo

37 tricky Selenium interview questions and answers


Hiring skilled software engineers with Selenium automated testing skills has become increasingly difficult due to global talent shortages and traditional hiring practices that don’t adequately assess candidates’ skills. 

In fact, research shows that by 2026 there may be 1.2 million unfilled software engineering jobs. [1] However, hiring high-quality software engineers isn’t just about filling vacancies, it’s also necessary to test candidates’ specific software engineering skills to avoid the costs of a mis-hire, like poor team dynamics, lost productivity, increased turnover, and employee burnout. 

This guide offers 37 Selenium tricky interview questions to evaluate candidates’ abilities to understand and use one of the most prominent automation testing tools on the market.

What are tricky Selenium interview questions? 

Tricky Selenium interview questions are designed to identify and evaluate candidates that can use this automation testing tool at an advanced level. 

These candidates may be applying for openings in software engineering, programming, or any other role that requires an in-depth understanding of automation testing. 

Selenium quote TestGorilla

Selenium is an open-source, automated testing tool that is used to test web applications across different browsers. 

Although Selenium can only test web applications (mobile and desktop apps are not included), it's a crucial tool in the testing phase of the software development life cycle. 

Why include tricky Selenium questions in your interviews? 

Hiring Selenium specialists begins with creating the perfect automation engineering job description that will attract the best professionals.

Next, tricky Selenium questions in your interview process elevates the top performers in your talent pool. 

Asking thought-provoking questions about Selenium isn’t just about testing a candidate’s memory of what the tool does, it helps the interviewer understand how a candidate processes information, communicates their thoughts, and responds to challenges under pressure. 

Below, we explore the benefits of including complex Selenium questions in your hiring process. 

Find candidates with advanced knowledge and application of Selenium 

Challenging questions give candidates an opportunity to showcase advanced knowledge, explain how Selenium works, why it functions the way it does, and how it can be used to overcome obstacles and accomplish role-specific tasks.

Identify and evaluate candidates’ soft skills 

Asking candidates complex questions not only assesses their technical skills and abilities, it encourages candidate responses that demonstrate soft skills like communication, problem-solving, and critical-thinking skills. 

These questions also enable interviewers to evaluate soft skills to determine whether a candidate can explain what Selenium concepts and practices mean in a work-related context rather than simply defining them. 

This could include describing the thought processes involved in navigating complex scenarios in Selenium WebDriver, like retrieving the value of specific attributes or handling multiple iframes in a window.

In addition to learning specific commands, candidates must apply their reasoning skills to solve automated testing problems, and choose the most effective solution from a list of options – all essential aspects of a software engineering role. 

Create a data-backed interview process 

Traditional unstructured interview questions provide a surface-level understanding of candidates' technical and soft skills and offer little hard data about how they will 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. 

It’s also important to keep in mind that tricky interview questions aren’t meant to trick the candidate. They move the interview away from practiced responses and open the floor for the interviewee to show off their detailed, provable skills related to Selenium automated testing. 

37 tricky Selenium interview questions and answers

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. 

1. How do you manage a frame in Selenium WebDriver? 


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: 

  1. Select iframe by ID using driver.switchTo().frame(“ID of the frame”);

  2. 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!");

  1. Locate iframe by tagName: driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));

  2. Locate iframe using index: driver.switchTo().frame(0);

  3. Switch back to the web content: switchTo().defaultContent()

2. Can you use Selenium alone to do responsive web design testing? 


In short, the answer is no. Interviewees should explain how Selenium is the best test automation tool for standard and responsive websites, but the tester also needs complementary tools to handle tasks like: 

  • Targeting RWD testing 

  • Visual validation 

  • Environment-based testing 

  • Accessibility compliance 

  • Quality analysis

3. What is a Robot class? 


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 onscreen for test automation and self-running demos, for example. 

4. What is Silk Test?


Silk Test is a tool for automated function and regression testing of enterprise applications that lets the user record application sessions, add test logic and verifications, and test playback to monitor the functionality of the applications. 

5. What are the different types of Selenium navigation commands? How do they help the user? 


Skilled candidates should list the following four commands and their functions: 

  1. navigate().forward(): This command navigates the user to the next web page based on browser history

  2. navigate().back(): This command navigates the user to the previous web page based on browser history

  3. navigate().to(): This command navigates the user to a new web page based on a specific URL while maintaining the browser history and cookies 

  4. navigate().refresh(): This command allows the user to perform a page refresh and is the most commonly used across test automation for page refreshing

6. What’s the difference between driver.close() and driver.quit() commands? 


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. 

7. Explain the differences between driver.findElement () and driver.findElements () in Selenium WebDriver


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.

8. What is the Page Object Model (POM) design pattern? How does it enhance test maintenance?


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, reducing the duplication of code. It separates the test logic from the UI structure, which simplifies maintenance as changes in UI can be localized to the corresponding page class.

9. What is TestNG in Selenium? 


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.

10. What is Page Factory in Selenium? 


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. 

11. What is parameterization in Selenium? 


Qualified candidates should explain what parameterization is but also how it functions in Selenium specifically. 

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. 

Candidates should also mention that this process can be conducted several times with various values. 

12. What is Selenium Grid and how does it work? 


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.

13. How do you get all the options in a dropdown in Selenium? 


To answer this question correctly, candidates should specify the getOptions method to obtain all options in a dropdown in Selenium. 

They should also 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. 

14. Explain the difference between getText() and getAttribute() in Selenium


Candidates should be able to articulate how the getAttribute() method provides the value of a particular HTML attribute and the getText() method provides the visible text of a web element. 

15. What are assertions in Selenium? What are the types? 


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: 

  1. 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. 

  2. 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()

16. How would you handle dynamic elements that change attributes or IDs on each page load?


For dynamic elements, 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, implement explicit waits to ensure the element is present before interacting, using ExpectedConditions to wait for specific conditions.

17. How do you use XPath in Selenium testing? 


Ideal answers should start by explaining what XPath is – an expression language, or syntax, for defining the elements of an XML document. 

Candidates should also touch on the benefits of XPath expressions to Selenium testing. These 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). 

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

18. What is the difference between findElement and findElements in Selenium? 


Candidates should be able to identify the subtle difference between these two commands as well as what these different methods provide the tester. 

  • findElement: This command identifies a web element in a web page

  • findElements: This command identifies the list of web elements in a web page

Look for answers that explain how findElement returns the object of the first matching element of the specified locator. They 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. 

19. How do you upload a file using Selenium WebDriver? 


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. 

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']"));


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. 

20. Explain how to handle browser cookies in Selenium WebDriver and some different scenarios it applies to. 


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

21. What are the advantages of using WebDriver Waits?


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.

22. Explain the concept of the FluentWait class in Selenium and how you would implement it.


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, create a FluentWait instance, set up its conditions and polling intervals, and then use it to wait for an expected condition to be satisfied.

23. What is the difference between getWindowHandle() and getWindowHandles()?


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.

24. How do you perform drag-and-drop operations in Selenium WebDriver?


To perform drag-and-drop, use the Actions class. 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.

25.  Explain how you would handle browser cookies using Selenium WebDriver.


To handle cookies, use methods provided by WebDriver, like addCookie(), getCookies(), and deleteCookieNamed(). These methods allow setting, retrieving, and deleting cookies as needed during test execution.

26. How can you simulate keyboard events using Selenium WebDriver?


To simulate keyboard events, use the Actions class. 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.

27. Explain the concept of DesiredCapabilities and how they are used in Selenium WebDriver.


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.

28. What is the difference between driver.navigate().to() and driver.get() methods?


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.

29. How can you simulate mouse hover actions using Selenium WebDriver?


To simulate mouse hover, 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.

30. How would you deal with dynamic wait times in Selenium tests?


Dynamic waits are essential for handling unpredictable delays. 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.

31. Explain how you would handle a scenario where a JavaScript alert is raised during test execution.


When a JavaScript alert appears, switch to it using driver.switchTo().alert(). Then, 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.

32. How can you execute JavaScript code using Selenium WebDriver?


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.

33. Explain how you would perform parallel test execution using Selenium WebDriver.


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.

34. What is the Chromium DevTools Protocol Integration in Selenium 4, and how does it enhance web testing capabilities?


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.

35. What are the limitations of Selenium WebDriver?


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.

36. What are Relative Locators in Selenium 4, and how do they simplify element identification?


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")));

37. How has Selenium 4 improved the interaction with iframes? Explain how you would switch to an iframe using the new approach.


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 others, like: 

  • By Web Element

  • By Index

  • By Name, or ID 

  • (driver.switchTo().frame("iframeNameOrId");)

How to include tricky Selenium interview questions in your hiring campaign

Tricky Selenium interview questions are an important part of the hiring process but they don’t tell the whole story of a candidate’s skills and personality. 

TestGorilla’s Selenium with Python test 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.

It’s also important to incorporate other multi-measure talent assessments as part of a holistic hiring process. 

A combination of tricky Selenium interview questions, skills tests, personality tests, and culture-add tests provide a comprehensive evaluation of a candidate’s technical abilities and soft skills. 

To understand how a candidate behaves in personal and professional settings, use our DISC or Enneagram tests. These personality assessments identify which behavior type motivates a particular candidate to take action and make decisions. 

Incorporating personality testing into your hiring process can indicate which candidates will work well in your team.

Explore TestGorilla’s extensive test library and create tailored assessments to locate, evaluate, and retain top-tier talent. 

How TestGorilla can help you find the best Selenium specialists

The trickiest questions force candidates to dive deep into specific methods, assertions, system processes, and best practices – everything they’ll need to succeed in their role. 

To get the most out of the tricky questions listed above, use them as part of a multi-measure testing technique. TestGorilla helps you to identify talent with the right technical skills, personality type, and behavioral attributes to benefit your organization. 

To explore all of the tests we have to offer, sign up for TestGorilla’s Free plan or request a free 30-minute live demo


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


Hire the best candidates with TestGorilla

Create pre-employment assessments in minutes to screen candidates, save time, and hire the best talent.

The best advice in pre-employment testing, in your inbox.

No spam. Unsubscribe at any time.

TestGorilla Logo

Hire the best. No bias. No stress.

Our screening tests identify the best candidates and make your hiring decisions faster, easier, and bias-free.

Free resources

Anti-cheating checklist

This checklist covers key features you should look for when choosing a skills testing platform

Onboarding checklist

This resource will help you develop an onboarding checklist for new hires.

How to find candidates with strong attention to detail

How to assess your candidates' attention to detail.

How to get HR certified

Learn how to get human resources certified through HRCI or SHRM.

Improve quality of hire

Learn how you can improve the level of talent at your company.

Case study
Case study: How CapitalT reduces hiring bias

Learn how CapitalT reduced hiring bias with online skills assessments.

Resume screening guide

Learn how to make the resume process more efficient and more effective.

Recruiting metrics
Important recruitment metrics

Improve your hiring strategy with these 7 critical recruitment metrics.

Case study
Case study: How Sukhi reduces shortlisting time

Learn how Sukhi decreased time spent reviewing resumes by 83%!

12 pre-employment testing hacks

Hire more efficiently with these hacks that 99% of recruiters aren't using.

The benefits of diversity

Make a business case for diversity and inclusion initiatives with this data.