Popular Selenium Interview Questions and Answers (1)

Last updated on February 20th, 2024 at 02:49 pm

Skills, Interviews, and Jobs

Popular Selenium Interview Questions and Answers for 2023

By November 16, 2022 8 min read

What is Selenium? What are the four components of Selenium? What are the advantages of Selenium automation testing? What are the limitations of Selenium? What are the most asked Selenium interview questions?

This blog post will help you answer these questions. 

Beginner-level Selenium interview questions

  1. What is Selenium?

    Selenium is an automated open-source testing framework that allows you to test web applications across different browsers. Selenium consists of a suite of tools that perform testing together.

  2. What are the components of Selenium?

    The four components of Selenium include…

    Selenium IDE

    Selenium IDE refers to Integrated Development Environment. It is an open-source record and playback test automation tool that allows you to record the steps as you navigate the workflow and analyze them later.

    Selenium RC

    Selenium RC refers to remote control that provides APIs for different programming languages, including Java, PHP, C#, Ruby, etc. With Selenium RC, you can write different testing scripts for various browsers.

    Selenium Web Driver

    Selenium Web Driver interacts natively with the browser and sends commands directly to get results.

    Selenium Grid

    Selenium Grid allows you to run parallel tests on different browsers using one server that acts as a hub. Cross-browser testing helps you save time by testing at scale.

  3. What are the different elements that you can find in Selenium?

    Different elements that you can find in Selenium include… 

    ID
    CSS
    Link Text
    Partial Link Text
    NameTag
    Attribute
    X-path

  4. What are the different testing types supported by Selenium?

    Selenium supports functional testing and regression testing.

    Functional testing tests the function of each component of an application.
    Regression testing rechecks already tested use cases to ensure they work as expected.

  5. What is Selenese?

    Selenese is a set of Selenium commands, including actions, accessors, and assertions.

    Actions are commands that interact directly with the application.
    Accessors allow you to define variables and store values.
    Assertions compare the current state of the application with the expected state.

    Selenese allows you to check Ajax functionality, alerts, list options, and broken links, among others.

  6. What are the different types of web locators used in the Selenium framework?

    Locators help Selenium IDE identify the elements it needs to operate on by specifying the area of action.

    Types of web locators used in Selenium include…

    Locator by ID
    Locator by link
    Locator by partial link 
    Locator by name 
    Locator by tag name 
    Locator by class name 
    Locator by XPath 
    Locator by CSS selector

    See Also: Top 21 Node JS Interview Questions and Answers for 2022

  7. What are the different types of navigation commands used in Selenium?

    Different types of navigation commands used in Selenium include…

    Driver. navigate(). Refresh () – This refreshes the current page
    Drive. navigate(). Forward () – This command helps you navigate forward on the browser
    Drive. navigate(). Back () – This command helps you return to the previous page of the browser.

    Selenium Intermediate-level interview questions

  8. What is X-path?

    X-path can help you locate HTML and XML elements based on their web path. X-path navigates the document’s XML or HTML structure to find specific elements on the page.

  9. What is the difference between single and double slash in X-path?

    A single slash in X-path starts selection from the document mode and creates absolute path extensions in the Selenium framework.

    On the other hand, a double slash in X-path can start selection from anywhere in the document and create relative path extensions.

    See Also: Top 21 SQL Interview Questions and Answers for 2022

  10. What is the difference between assert and verify commands in Selenium?

    In the Selenium framework, the assert command allows you to check for a particular element on a page. The assert command stops the check when an asserted element is not available.

    On the other hand, the verify command also checks for a particular element on a page. The verify command does not stop the check when the asserted element is not available and continues the search on other pages.

  11. What is the use of JUnit in Selenium?

    JUnit is an open-source framework for conducting unit testing of Java-based applications. JUnit annotation is metadata that JUnit provides to the method to perform specific actions. By using JUnit annotations with Selenium, you can organize and maintain test cases.

    Selenium WebDriver testing with JUnit annotations in the script can distinguish between initialization tasks, the actual tests, and post-execution tasks.

  12. What are the different types of JUnit annotations in Selenium?

    @BeforeClass
    @Before
    @Test
    @After
    @AfterClass
    @Ignore
    @ParameterizedTest
    @RunWith
    @RepeatedTest
    @Parameters

  13. What are the different types of wait commands supported in Selenium?

    In Selenium automation testing, wait commands ask test execution to pause for some time before continuing with the next step. Selenium supports four types of wait commands that include…

    Implicit wait – Implicit wait waits for some time before throwing the ‘no such element’ exception.

    Explicit wait– Explicit wait informs the web driver to wait for certain conditions before throwing the ‘Element not visible’ exception in Selenium automation testing.

    Fluent wait- Fluent wait also informs the web driver to wait for certain conditions and the frequency to check these conditions before throwing the ‘Element not visible’ exception.

    WebDriver wait: WebDriver wait is ideal for dynamic testing, as it checks for conditions every second and proceeds with the next command in the script upon meeting the previous condition.

    See Also: Top 20 TypeScript Interview Questions and Answers for 2022

  14. How to type text in the input box in Selenium?

    In the Selenium framework, sendKeys is the method to type text in the input box.

    Here are the steps to enter text in the input box in Selenium

    Use WebElement email = driver.findElement(By.id (“email”) ) to find the email text using the ID locator.
    Use email.sendKeys (“abcdefghi@gmail.com”) to enter text in the URL field
    Use WebElement password =driver.findElement (By.id (“Password”) finds the password text using the ID locator.
    Use password.sendKeys (“abcdefgh123”) to enter text in the password field.

  15. How to click on a hyperlink in Selenium?

    To click on a hyperlink in Selenium, use the driver.findElement(Bylink.text) command. This command uses the specific information in the substring (Bylink.text) to access a particular hyperlink.

  16. How to scroll a page using JavaScript in Selenium?

    In the Selenium framework, the scrollBy() method helps you scroll a web page.

    Here are the steps to scroll a page using JavaScript in Selenium:

    First, create a JavaScript object with JavascriptExecutor js = (JavascriptExecutor) driver;

    Launch the desired application with driver.get(“https://www.amazon.com”);

    Scroll down to the desired location using js.executeScript(“window.scrollBy(0,1000)”);

  17. How to retrieve the CSS properties of an element?

    To retrieve the CSS properties of an element, use the getCSSValue method

    For example, driver.findElement(By.id(“email“)).getCssValue(“font-size”)

    See Also: Top 21 Vue JS Interview Questions and Answers for 2022

  18. What is TestNG and what are its advantages?

    TestNG is an open-source automated testing framework where NG stands for next generation. TestNG can help you set, map, and control test cases and their execution with features like grouping, sequencing, parameterizing, and annotations in test cases.

    Advantages of TestNG

    TestNG generates logs
    Annotations are easy to understand
    TestNG does not extend the test class
    Each test case can be independent of another
    Parallel execution of multiple test cases

    Advanced-level Selenium interview questions

  19. What are the different WebDriver-supported mobile testing drivers in Selenium?

    There are four WebDriver-supported mobile testing drivers in the Selenium framework. They are as follows:

    AndroidDriver can test Android applications both on real devices and emulators.
    IPhoneDriver can be used to test iOS applications.
    RemoteWebDriver can be used to test web applications on mobile devices with a variety of browsers.
    Selendroid can be used to test Android applications both on real devices and emulators.

  20. How to handle Ajax calls in Selenium WebDriver?

    An Ajax call is an asynchronous request that allows the user to work on the application while waiting for a response. Ajax sends HTTP requests from the client to the server that the server responds to without loading the entire webpage.

    While making an Ajax call, you are unsure about the server’s response time. Thus, the major challenge of handling an Ajax call in Selenium is the loading time of the webpage.

    Since the loading of a webpage can last from a fraction of a second to a few seconds, you need to use the wait method instead of Selenium automation testing.

    The different wait methods that you can use to handle an Ajax call in Selenium include implicit wait, explicit wait, fluent wait, and WebDriver wait.

    See Also: Top 21 AWS Interview Questions and Answers for 2022

  21. What is the importance of session handling in Selenium?

    Session handling refers to the process of managing server responses to preserve application state information during load testing. Without session handling, you may get a request for another script in the same browser before completing your test execution.

    In the Selenium framework, you can perform session handling with Selenium WebDriver and TestNG framework. The TestNG framework consists of parallel attributes, thread count, and TestNG execution. You must set the value of parallel attributes to the method to enable thread count to control the number of sessions created during test execution.

  22. What is desired capability and why is it necessary for Selenium?

    Desired capability consists of key-value pairs that store information on different browser properties like browser name, browser version, and path of browser driver, among others to determine browser behavior at runtime.

    In the Selenium framework, desired capability configures the driver instance of Selenium WebDriver. This action allows you to run the test cases on a different browser with different versions and operating systems.

  23. What are breakpoints and start points in Selenium?

    Break points help you check code structure and execution. When you apply a breakpoint to any code it debugs the code step by step allowing you to verify the code.

    Start points help you identify the point from which execution must begin. Start points can run a test script from the middle of a code or a breakpoint.

  24. What is an object repository and how can we create it in Selenium?

    Object repository refers to a collection of web elements along with their locator values. When you need the locator values of any element in the script you can use the object repository. It stores the locator values in a centralized location instead of hardcoding them in the script.

    To create an object repository in Selenium you must use the key and value pair. The key refers to the name of an object, whereas the value consists of the property of an object that helps you identify the object on the webpage uniquely.

    There are two types of object repositories in the Selenium framework, they are as follows:

    Object repository using the XML file

    Here are the steps to create an object repository using an XML file:

    Go to package, then new, and then file
    Create an XML file with.xml as an extension in the project
    Store the locator’s path in the XML file
    Write the script to get data from the XML file
    Use different paths to add web elements in the XML file

    Object repository using the properties file

    Here are the steps to create an object repository using a properties file:

    Go to package, then new, and after that file
    Create a file using .properties as an extension
    Store different values in the key-value format
    Write the code to get data from the properties file

    See Also: Top 21 Angular Interview Questions and Answers for 2022

  25. What is the code to fetch data from the properties file?

    Here is the code to fetch data from the properties file:

    Selenium Interview Questions
  26. What is the code to fetch data from an XML file?

    Here is the code to fetch data from the XML file: 
    Selenium interview questions

Summary

Selenium is a popular testing framework that offers a wide suite of testing tools. If you are preparing for a Selenium interview, you must brush up your knowledge to increase your chances of getting the job.

Are you a skilled software developer looking for high-paying remote software jobs with top US companies?

Try Turing and land your dream jobs in React, Node, Selenium, Python, Angular, Swift, React Native, Android, Java, Rails, Golang, DevOps, ML, Data Engineers, and much more. Visit the Apply for Jobs page today.


FAQs

  1. What are the advantages of Selenium automation testing?

    The advantages of Selenium automation testing include…

    Parallel execution
    Implementation of repeated text cases 
    Ability to test large test matrix 
    Improved accuracy 
    Reduced costs

  2. What are the limitations of Selenium?
  • Selenium does not offer vendor support 
  • Selenium generates reports through third-party tools like TestNG and JUnit
  • Selenium cannot test mobile applications 
  • Selenium cannot test barcode and captcha readers 

Join a network of the world's best developers and get long-term remote software jobs with better compensation and career growth.

Apply for Jobs

Summary
Popular Selenium Interview Questions and Answers for 2023
Article Name
Popular Selenium Interview Questions and Answers for 2023
Description
Popular Selenium Interview Questions 1. What is Selenium? 2. What are the components of Selenium? What are the different elements that you find in Selenium?
Author

Author

  • Ashwin Dua

    Ashwin is a content writer who has written several content types and has worked with clients like IRCTC, Hero Cycles, and Fortis Healthcare, among others.

Comments

Your email address will not be published