Selenium Interview Questions and Answers

Thumb

Author

BIQ

Questions

19

Last updated

Feb 6, 2023

An open-source and free to use automation test tool, Selenium is used to test web applications. Developers use this tool to run test cases directly in web browsers. Selenium supports most of the popular web browsers, including IE, Chrome, Firefox, Safari, and Opera. Developers are free to use programming languages such as Java, Javascript, Python, and PHP to write a test case in Selenium and then running the script to verify test cases in most of the popular web browsers. We have added an interview -specific information to our Selenium Interview Questions. Do not forget to read them!

Developers can run automation test scripts in Windows, Linux an Mac, and can be deployed on Android, iOS and Windows. Selenium is recognized as the most portable, open-source test tool for web application automation. You can now read our updated and huge collection of Selenium Interview Questions.

Most Frequently Asked Selenium Interview Questions

Here in this article, we will be listing frequently asked Selenium Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q1. What are the advantages of Selenium as a test tool?
Answer
  • It is free and open source
  • Has large user base and online communities
  • Cross-browser compatibility
  • Platform compatibility
  • Supports most of the programming languages
Q2. What are the different components in Selenium?
Answer

The Selenium suite includes 4 set of tools:

 

1. Selenium Integrated Development Environment (IDE): It is a record and playback tool, which is distributed as a Firefox Plugin.

2. Selenium Remote Control (RC): It is a server that allows users to create test scripts in the programming language of their choice. It also allows developers to execute test scripts cross browsers.

3. Selenium WebDriver: This tool communicates directly with the browser and uses native compatibility to automate.

4. Selenium Grid: It is used to distribute test execution on multiple platforms and environments

Q3. What are testing types supported by Selenium?
Answer

Selenium supports two types of testing - Functional Testing and Regression Testing.

Q4. What is the purpose of Selenium IDE?
Answer

It is the easiest and simplest tool in the Selenium Package. Two features - record and playback - make this tool very easy to learn with minimum knowledge of other programming languages. Selenium IDE is the best tool for new users.

Q5. What do you mean by Selenese?
Answer

It is the language for writing test scripts in Selenium IDE.

Q6. How many types of locators are there in Selenium?
Answer

The locator is an address that identifies a web element within the page. Different types of locators are used to identify different web elements accurately in Selenium:

  • ID
  • ClassName
  • Name
  • TagName
  • LinkText
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM
Q7. How is Assert command different from Verify command?
Answer
S.no Assert command Verify command
1. Sees if a given condition is true or false. Sees if the condition is true or false
2. If the condition is true, program control will execute the next test step. Irrespective the conditions are true or false; the program does not stop.
3. If the condition is not true, execution will stop, and no test will be executed. All of the test steps get executed.
Q8. Explain XPath.
Answer

XPath can help the developers locate web elements based on their XML path. The logic behind establishing HTML elements using XPath is the crossing between different parts across the page, which enables a user to find the item through the reference to another aspect.

 

If you are preparing for Selenium interviews, you can have a look at our Advanced Selenium Interview Questions for better insight.

Q9. How are Selenium IDE, WebDriver and Selenium RC different from each other?
Answer
Selenium IDE Selenium RC WebDriver
Only supports Firefox Supports a range of browsers like Firefox, Chrome, IE, and Opera Supports Firefox, Chrome, IE, Opera, and HtmlUnitDriver.
Supports playback and record features Does not support record and playback Does not support record and playback
Does not require server before executing test scripts Needs server before executing test scripts Does not require server before executing test scripts
Javascript-based framework JavaScript-based framework Uses browser's native compatibility for automation
Not object-oriented Semi object-oriented Completely object-oriented

 

You are expected to know this information during Selenium Interview Questions With Answers.

Q10. What is the use of Selenium Grid?
Answer

Selenium Grid is used for executing test scripts on multiple platforms and cross-browsers simultaneously to achieve distributed test execution under different environments, thus saving program execution time.

Q11. What are Selenium 1 and Selenium 2?
Answer

Selenium RC and WebDriver, when combined, are known as Selenium 2. Selenium RC is also known as Selenium 1.

Q12. Name the different types of waits in WebDriver.
Answer

Two types of waits are available in WebDriver - Implicit Wait and Explicit Wait.

Implicit waits provide default waiting time between each consecutive test step across the test script. Therefore, subsequent test steps will execute only when the waiting time has elapsed after the previous test step.

Explicit waits halt the execution till the time a given condition is met or the maximum wait time has elapsed. Unlike Implicit wait, the explicit wait can be applied only in particular instances.

Q13. What are the uses of findElement() and findElements()?
Answer

findElement(): This is used to find the first element on the existing web page matching the specified locator value. You must remember that only first matching element will be fetched.

findElements(): This is used to find all of the elements in the existing web page matching the specified locator value. You must remember that all of the matching elements will be fetched and saved in the WebElements list.

Q14. How is driver.close()command different from driver.quit command?
Answer
S.no close() quit()
1. Closes the browser window currently being used or accessed by WebDriver Closes down all the windows that were opened by the program
2. Neither requires parameters nor returns values. Neither requires parameters nor returns values.
Q15. Is Selenium capable of handling Windows pop-ups?
Answer

No. Selenium is an automation testing tool that only supports web application testing. It cannot handle Windows pop-ups.

This is one of the frequently asked Selenium Interview Questions.

Q16. How are web-based pop-ups handled in Selenium?
Answer

WebDriver offers an efficient way to handle web-based pop-ups using the Alert interface. Developers can use the below mentioned four methods, along with the Alert interface, for treating web-based pop-ups:

  • void dismiss(): Accept() way clicks “Cancel” when window pop-ups appear.
  • void accept(): Accept() method clicks “Ok” button when window pop-ups appear.
  • String getText(): GetText() method returns the text shown on alert box.
  • void sendKeys(String stringToSend): SendKeys() method enters specified string pattern into alert box.
Q17. Explain Junit. What are annotations?
Answer

It is a unit testing framework, which was introduced by Apache. This framework is based on Java.

 

Following are JUnit Annotations:

  • @Test: This annotation tells the system that any method that is annotated as @Test is test method. You can have multiple test methods in one script.
  • @Before: This shows the system that this method will be executed every time before the test method.
  • @After: This method tells the system that this method will get performed every time after the test method.
  • @BeforeClass: This method determines the system that this method will get performed once before any of the test methods.
  • @AfterClass: This method determines the system that this method will get performed once after the test method.
  • @Ignore: It shows the system that this method will not be implemented.
Q18. How is TestNG better than Junit?
Answer

TestNG is an advanced framework that helps both developers and testers leverage the benefits. An open source framework, it is distributed under the Apache Software License.

These features make TestNG better than Junit:

  • Tests to confirm the code is multithread safe
  • Supports data-driven testing
  • Supports parameters
  • Includes a variety of tools and plug-ins
  • Flexible test configuration
  • Possible to set test case dependencies
Q19. How is Selenium different from QTP?
Answer
S.no Selenium QTP
1. Open source License required
2. Free of cost High price
3. Supports Windows, Linux, Mac Supports only Windows
4. Extensive language support Support only VB Script