25+ Selenium Interview Questions And Answers


Most Frequently asked Java Interview Questions:

Selenium Interview Questions, In this post we see both basic and advanced level question along with answers. Our main focus is on Selenium WebDriver Interview Questions and also we write TestNG Interview Questions & Selenium Automation Interview Questions too

Q1. What is Automation Testing?

Ans: Automation testing is the process of testing a software or application using an automation testing tool to find the defects. In this process, executing the test scripts and generating the results are performed automatically by automation tools.

It is required when we have huge amount of regression test cases. Some most popular tools to do automation testing are HP QTP/UFT, Selenium WebDriver, etc.

Q2. What are the benefits of Automation Testing?

Ans: This is one of the common interview questions in any Automation testing job.

  • Saves time and money. Automation testing is faster in execution.
  • Object Oriented Programming Language - Unlike C++, Java is purely OOP.Java is a fully object-oriented programming language. It has all OOP features such as abstraction, encapsulation, inheritance and polymorphism.
  • Reusability of code. Create one time and execute multiple times with less or no maintenance.
  • Easy reporting. It generates automatic reports after test execution.
  • Easy for compatibility testing. It enables parallel execution in the combination of different OS and browser environments.
  • Low-cost maintenance. It is cheaper compared to manual testing in a long run.
  • Automated testing is more reliable.
  • testing is more powerful and versatile. Automation tools allow us to integrate with Cross Browser Testing Tools, Jenkins, Github etc.
  • It is mostly used for regression testing. Supports execution of repeated test cases.
  • Minimal manual intervention. Test scripts can be run unattended.
  • Maximum coverage. It helps to increase the test coverage.

Q3. What are the challenges and limitations of Selenium WebDriver?

As we all know Selenium WebDriver is a tool which automates the browser to mimic real user actions on the web. Selenium is a free open source testing tool. Some of the challenges with selenium webdriver are as follows

  • We cannot test windows application
  • We cannot test mobile apps
  • Limited reporting
  • Handling dynamic Elements
  • Handling page load
  • Handling pop up windows
  • Handling captcha

Q4. What type of tests have you automated?

Our main focus is to automate test cases to do Regression testing, Smoke testing, and Sanity testing. Sometimes based on the project and the test time estimation, we do focus on End to End testing.

Q5. How many test cases you have automated per day?

Ans: It is one of the Selenium Tricky Interview Questions.

Actually it depends on Test case scenario complexity and length. I did automate 2-5 test scenarios per day when the complexity is limited. Sometimes just 1 or fewer test scenarios in a day when the complexity is high.

Q6. What is a Framework?

Ans: A framework defines a set of rules or best practices which we can follow in a systematic way to achieve the desired results. There are different types of automation frameworks and the most common ones are:

  • Data Driven Testing Framework
  • Keyword Driven Testing Framework
  • Hybrid Testing Framework
  • Behavioural Driven Framework

Q7. Have you created any Framework?

Ans: If you are a beginner: You can say “No, I didn’t get a chance to create framework from the scratch. I have used the framework which is already available. My contribution is mostly in creating test cases by using the existing framework.”

If you are a beginner but have good knowledge on creating framework: You can say “Yes, I have involved in developing framework along with other automation tester in my company.”

If you are an experienced tester: You can say “I have contributed in developing framework.” or You can say “Yes, I have created framework from the scratch. There was no automation process in my previous company. I designed the framework from the scratch.”

Q8. Why do you prefer Selenium Automation Tool?

I prefer Selenium Automation Tool because some of the benefits of Selenium to do automation testing are:

  • Ans: Free and open source - It is a free open source tool. There is no need to allot budget for this tool

  • Help - Have large user base and helping communities.

  • Cross-browser compatibility - It works on almost all popular browsers such as Chrome, Firefox, Internet Explorer, and Safari.

  • Cross Platform compatibility - It works on platforms such as Windows, Linux, Mac.

  • Multiple programming languages - It supports programming languages such as Java, Phyton, Perl, Php, C#, Ruby, etc.,

  • Parallel Execution - Selenium Grid supports parallel execution of Selenium Scripts.

  • Continuous Integration - We can achieve nightly execution using Jenkins.

Q9. What is Selenium?

Ans: WSelenium is an open source (free) automated testing suite to test web applications. It supports different platforms and browsers. It has gained a lot of popularity in terms of web-based automated testing and giving a great competition to the famous commercial tool HP QTP (Quick Test Professional) AKA HP UFT (Unified Functional Testing).

Selenium is a set of different software tools. Each tool has a different approach in supporting web based automation testing.

It has four components namely,

  • Selenium IDE (Selenium Integrated Development Environment)
  • Selenium RC (Selenium Remote Control)
  • Selenium WebDriver
  • Selenium Grid

Q10. What is Selenium IDE?

Selenium IDE (Integrated Development Environment) is a Firefox plugin. It is the simplest framework in the Selenium Suite. It allows us to record and playback the scripts. Even though we can create scripts using Selenium IDE, we need to use Selenium RC or Selenium WebDriver to write more advanced and robust test cases.

Q11. What is Selenese?

Selenese is the language which is used to write test scripts in Selenium IDE.

Q12. Which is the only browser that supports Selenium IDE to be used?

Ans: Firefox

Q13. What is Selenium RC?

Ans: Selenium RC AKA Selenium Remote control / Selenium 1. Selenium Remote Control was the main Selenium project for a long time before the WebDriver merge brought up Selenium 2. Selenium 1 is still actively supported (in maintenance mode). It relies on JavaScript for automation. It supports Java, Javascript, Ruby, PHP, Python, Perl and C#. It supports almost every browser out there.

Q14. What is Selenium WebDriver?

Ans: Selenium WebDriver AKA Selenium 2 is a browser automation framework that accepts commands and sends them to a browser. It is implemented through a browser-specific driver. It controls the browser by directly communicating with it. Selenium WebDriver supports Java, C#, PHP, Python, Perl, Ruby.

Q15. What is Selenium Grid?

Ans: Selenium Grid is a tool used together with Selenium RC to run tests on different machines against different browsers in parallel. That is, running multiple tests at the same time against different machines running different browsers and operating systems.

In simple words, it is used to distribute your test execution on multiple platforms and environments concurrently.

Q16. When do you use Selenium Grid?

Ans: Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution

Q17. What are the advantages of Selenium Grid?

  • It allows running test cases in parallel thereby saving test execution time.
  • It allows multi-browser testing
  • It allows us to execute test cases on multi-platform

Q18. What is a hub in Selenium Grid?

A hub is a server or a central point that controls the test executions on different machines.

Q19. What are the types of WebDriver APIs available in Selenium?

  • Firefox Driver
  • Gecko Driver
  • InternetExplorer Driver
  • Chrome Driver
  • HTMLUnit Driver
  • Opera Driver
  • Safari Driver
  • Android Driver
  • iPhone Driver
  • EventFiringWebDriver

Q20. What is a node in Selenium Grid?

Node is the machine which is attached to the hub. There can be multiple nodes in Selenium Grid.

Q21. Which WebDriver implementation claims to be the fastest?

Ans: The fastest implementation of WebDriver is the HTMLUnitDriver. It is because the HTMLUnitDriver does not execute tests in the browser. Starting a browser and running test cases took more time compared to running the scripts without a browser. HTMLUnitDriver took a simple HTTP request-response mechanism for test case execution.

Q22. What are the testing types that can be supported by selenium?

Testing types that can be supported by Selenium are as follows:

  • Functional Testing
  • Regression Testing
  • Retesting
  • Acceptance Testing
  • -to-End Testing
  • Smoke Testing
  • Sanity Testing
  • Responsive Testing
  • Cross Browser Testing
  • UI Testing
  • Integration Testing

Q23. What is an XPath?

XPath is used to locate the elements. Using XPath, we could navigate through elements and attributes in an XML document to locate web elements such as textbox, button, checkbox, Image etc., in a web page.

Q24. When you use these locators ID, Name, XPath, Or CSS Selector?

Ans:

ID & Name locators will be used when there are unique identifiers & unique names available on the web page.

CSS Selector can be used for performance and when ID & Name locators are not unique.

XPath is used when there is no preferred locators.

Q25. What is the difference between “/” and “//”

Single Slash “/” –Single slash is used to create XPath with absolute path i.e. the XPath would be created to start selection from the document node/start node.

Double Slash “//” – Double slash is used to create XPath with relative path i.e. the XPath would be created to start selection from anywhere within the document.

Q26. What are Soft Assert and Hard Assert in Selenium?

Ans: Soft Assert: Soft Assert collects errors during @Test Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement.

Hard Assert: Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next @Test.

Q27. What is WebElement selenium?

WebElement in Selenium represents an HTML element. It basically represents a DOM element in a HTML document.

Q28. What is Implicit Wait In Selenium WebDriver?

Ans: Implicit waits tell to the WebDriver to wait for a certain amount of time before it throws an exception. Once we set the time, WebDriver will wait for the element based on the time we set before it throws an exception. The default setting is 0 (zero). We need to set some wait time to make WebDriver to wait for the required time.

Q29. What is WebDriver Wait In Selenium WebDriver?

Ans: WebDriverWait is applied on a certain element with defined expected condition and time. This wait is only applied to the specified element. This wait can also throw an exception when an element is not found

Q30. What happen if you mix both implicit wait and explicit wait in a Selenium Script?

Ans: As per the official Selenium documentation, it is suggested not to mix both Implicit waits and Explicit Waits. Mixing both of them can cause unpredictable wait times.

Implicit wait is defined only once in the code. It will remain same throughout the driver object instance.

Explicit wait is defined whenever it is necessary in the code. This wait will call at the time of execution. It is a conditional wait.

Explicit wait will overwrite the implicit wait where ever explicit wait is applied. So, Explicit Wait gets first preference then Implicit Wait.

Get The Coaching Training Today!