Selenium Interview Questions and Answers

Selenium Interview Questions and Answers, Interview Questions on Selenium WebDriver, Java Programming, TestNG Testing Framework, Maven, Jenkins, and Selenium Automation Framework Design & Implementation.

Selenium Interview Questions and Answers for Fresher and Experienced.

1. What are the Test types supported by Selenium?

According to Selenium’s official website (selenium.dev), It supports Functional Testing in System Testing Level and Functional Testing in Acceptance Testing Level.

Selenium also supports some sorts of Performance Testing (Load Testing and Stress Testing), but it is not recommended for Performance Testing, because It was not designed for that. It was designed for Functional Testing of Computer web applications.

Selenium also supports BDD (Behavior Driven Development) and TDD (Test Driven Development) methodologies.

2. What are the important features of Selenium?
  • Selenium supports various Operating environments (MS Windows, Linux, Macintosh) to conduct Testing.
  • Selenium supports various Programming Languages (Java, Python, C#.Net, Ruby, JavaScript, and Kotlin) fro writing Test Cases
  • Selenium supports various Browsers (Google Chrome, Mozilla Firefox, MS Edge, Opera, and Safari) to execute the Test Cases.
  • Selenium supports Batch Testing, Data-Driven Testing, Cross Browser Testing, and Database Testing.
  • Selenium supports Parallel Testing.
3. What are the programming languages that are supported by Selenium to write test cases?

Selenium WebDriver supports six programming languages to write test cases, you can use any one of those languages, they are,

1. Java
2. Python
3. C#
4. Ruby
5. JavaScript
6. Kotlin.

Note: Java language is popular for Selenium testing, it has nearly 70% market share, and all remaining languages are having below 30% market share only.

4. What is the most preferred Element locator by Selenium?

Selenium supports eight-element locators to locate/identify/recognize elements in web pages, they are,

id
name
className
tagName
linkText
particialLinkText
cssSelector
xpath

If we find a unique id locator for any element then use the id locator for that element, it is quicker.

5. What is the use of Testing Framework in Selenium?

We use Testing Framework (Basically Unit Test Framework) for Selenium as Test Runner. Using Testing Framework like JUnit or TestNG we can Create Test Batches, Prioritize Test Cases, Grouping Test Cases, Execute Test Batches, and Generate Test Reports.

6. How to Select a Testing Framework for Selenium?

In Selenium, Testing Framework selection depends on the Programming platform that we selected for Selenium,

If Select Java for Selenium then supported Testing Frameworks are either JUnit or TestNG, suppose if we select Python for Selenium then supported Testing Frameworks are Robot or PyTest or PyUnit…

7. Is Selenium supports Acceptance Testing?

Yes, Selenium supports Acceptance Testing, but not all types of Testing in Acceptance Testing Level, it supports only Functional Testing in Acceptance Testing Level.

8. What are the advantages of Maven integration with Selenium?

Basically, Maven is a Build Automation Tool for Java projects. In Selenium, it is for Test Environment setup and Maintenance of the Test Environment.

Advantages of Maven Integration with Selenium

i. Selenium Test Environment Setup
(Add software dependencies code to Maven POM XML of Maven Tool, then it downloads the software and configure.)

ii. Selenium Test Environment Maintenance
(Add new version/s of software dependencies, and then it can update the environment)

iii. Providing common configuration for all Team members

9. What is POM in Selenium?

POM (Page Object Model) is used for creating Object Repositories In Selenium, if we integrate Maven with Selenium, you can find one more POM (Project Object Model) for adding Software Dependencies in the XML file of Maven Tool.

10. How to conduct Positive and Negative Testing using a single Test Case?

Using Selenium Data-Driven Test Case we can conduct Positive and Negative Testing. We use valid input for Positive Testing and Invalid input for Negative Testing.

11. What is Selenium Licence?

Selenium is Open source software, but it has a license called Apache 2.0, we can download Selenium and use it with free of cost, we can modify the Selenium source code and distribute it to others, but selling the modified code is not allowed, and it is the core objective of Apache 2.0 license.

12. What are the Prerequisites to write Selenium Test Cases?

Prerequisites to write Selenium Test Cases:

i. Manual Test Cases for Automation
ii. Web/HTML Element locators to locate elements in web pages
iii. Selenium WebDriver Commands/Methods for performing actions on the Elements.
iv. Programming features (Ex: Java or Python) to enhance Test Cases
v. Testing Framework (Ex: JUnit or TestNG) to create Test Batches, Prioritize Test Cases, Grouping Test Cases, and Inserting verification points, etc.

13. How to automate “Captcha” fields using Selenium?

According to Selenium Documentation, Automating Captcha (Verification Code) is the worst practice, the actual purpose of Captcha is to avoid Automation users, so it is not recommended to automate Captcha fields using Selenium.

14. Is Selenium supports Database Testing?

Basically, Selenium doesn’t have any facility to communicate with Databases. Using the Programming Database connectivity feature (Ex: JDBC in Java) it can connect to Databases and conducts Database Testing.

15. How to handle “PopUp windows” using Selenium?

Selenium WebDriver offers the users a very efficient way to handle Popups using the Alert interface.

dismiss() – The dismiss() method clicks on the “Cancel” button as soon as the popup window appears.

accept() – The accept() method clicks on the “Ok” button as soon as the popup window appears.

getText() – The getText() method captures the error message from popup window.

16. What is Test independency?

Writing each Test as its own unit. Writing the tests in a way that will not be reliant on other tests to complete.

Selenium Interview Questions and Answers.

17. What about Selenium Certification?

According to Selenium’s official website (selenium.dev) there is no recognized certification for Selenium, some training institutions are offering Selenium certification but they are invalid.

18. Is Selenium supports Database testing?

yes, but Selenium doesn’t connect with databases directly, with the support of Programming it supports database testing, suppose if we use Java for Selenium then using Java JDBC we can connect with databases and conduct database testing,

19. Why do we need to use different locators for locating elements?

Selenium supports 8 HTML element locators to locate elements and we can use any one unique locator to locate an element. We may use different locators for our web elements, because,

  • Some locators are not applicable for all types of elements
    Ex: linkText() and partialLinkText()
  • Some locators may be duplicated
  • All locators may not visible for every element
20. How to inspect Web or HTML Elements?

Using a web browser built-in feature (Google Chrome or Mozilla Firefox or MS Edge)
Firefox – Page Inspector
Chrome/Edge – Developer Tools (F12)

Note: Three or Four years back we used separate plug-ins for browsers (Example: Firebug and Firepath plug-ins for Mozilla Firefox browser)

21. What are important Web/HTML Elements?

Browser,
Page,
Frame,

Note: Above are not web elements, they are containers for elements, 

1. Text Link – It redirects.
2. Edit box – It takes input
3. Text box – It takes input
4. Comment box – It takes input
5. Button – It submits
6. Image – Visible
7. Image Link – It redirects.
8. Image Buttons – It submits
9. Dropdown box – It selects an item
10. List box – It selects one or more items
11. Combo box – (Dropdown box + Edit box)
12. Check box – It checks/Uncheck
13. Radio Button – It selects
14. Web Table / HTML Table – It displays the data in a tabular format.
15. Text/Help message/Error message/Content Headers/Content – It displays a message/text for reading.

Below are not web elements, they are just arrangements, 

Popup
Mouse Hover
Date Picker
Calendar
Inline Elements

22. What are important actions on web browsers?

Important Actions on Browsers while Web functional testing:

  • Launch a Browser
  • Maximize the Browser window
  • Browser window Fullscreen
  • Delete all cookies
  • Launch a Web page
  • Return the Page Title
  • Return the current browser’s URL
  • Navigate to another page
  • Back to the previous page
  • Forward
  • Refresh the Browser window
  • Close the Browser window
  • Close all browsers windows
23. How to conduct Parallel testing using Selenium?

Parallel testing in Selenium is a process where you run the same tests simultaneously in different environments. The primary purpose of executing tests in parallel is to reduce the overall time and efforts of automated browser testing while ensuring a quality product by using a Selenium Grid.

24. What is XPath in Selenium?

XPath, also known as XML Path, is one of the most commonly used locators in Selenium WebDriver that can help you navigate through the HTML structure of a page. It can be used for HTML and XML documents to locate any element in a web page using HTML DOM structure.

There are two types of XPath:

Absolute XPath
Syntax: html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b

Relative Xpath

Syntax:
//*[@class=’featured-box’]//*[text()=’Testing’]

25. What is Web/HTML Element Locator?

It is an address that identifies a web element uniquely within a web page.

Selenium supports eight locators, you can use any one of those locators to locate an element by Selenium.

1. id()
2. name()
3. className()
4. tagName()
5. linkText()
6. partialLinkText()
7. cssSelector()
8. xpath()

26. Do you have web application environment knowledge?

Yes, I have some knowledge on web technologies to conduct web testing.

1. HTML – To design web pages
2. XML – Data Transporter
3. CSS – Enhancing Web page design
4. Client-side scripting – (JavaScript)
5. Server-side sripting – (VBScript)
6. Containers – ASP, JSP
7. Web servers – Apache web server, Java web server, IIS, etc,
8. Applicatio Servers – COM+, JBoss, WebLogic, WebSpeare, etc,
9. Database servers

  • SQL Databases / Relational Databases – Oracle, MS SQL Server, MySQL, SyBase, DB2, etc,
  • NoSQL Databases/Non-Relational Databases – MangoDB, Casandra, CoutchDB, etc,

10. EDP – Programming (Java/.NET)

27. Why do we use multiple locators to locate web element in web pages?
  • Some locators are not applicable for all types of elements.
    Ex: likText() and partialLinkText()
  • All locators may not visible for every element.
  • Some locators may be duplicated.
28. What are the tips on using using selectors or locators in Selenium?

According o Selenium guidelines,

  • In general, if HTML IDs are available, unique, and consistently predictable, they are the preferred method for locating an element on a page.
  • If unique IDs are unavailable, a well-written CSS selector is the preferred method of locating an element. XPath works as well as CSS selectors, but the syntax is complicated and frequently difficult to debug.
  • Selection strategies based on linkText and partialLinkText have drawbacks in that they only work on link elements.
  • Tag name can be a dangerous way to locate elements. There are frequently multiple elements of the same tag present on the page.
29. How to get unique locators for locating elements?
  • Follow Selenium tips on using Selectors.
  • Perform dry run/s (sample run/s) and identify unique locators.
30. What are the different states of a browser?
  1. Minimised
  2. Maximised
  3. Full Screen
  4. Resized
31. What is the Page Object Model (POM)?

POM (Page Object Model) is a design pattern responsible for creating an Object Repository for web UI elements in Selenium.

We can use POM in two ways:
1. POM with Page factory
2. POM without Page factory

32. What is Object Repository?

Object Repository refers to a collection of web elements belonging to Application Under Test (AUT) along with their locator values. Object Repository is used to store locators in a centralized location.

33. What are the limitations of Selenium?

Selenium has rich features, it has some limitations along with those features:

  • It is not an all inclusive test tool, it requires some third party plug-ins and frameworks in order to broaden the scope of testing.
  • It supports testing of only web-based applications
  • Selenium can’t test Captcha and Barcode readers
  • It doesn’t have built-in result report facility, it generates reports using third-party tools like TestNG or JUnit.
  • No reliable technical support since it is an open source tool.
34. Does Selenium WebDriver support web services testing?

No, Selenium WebDriver automates web applications using the browser’s native method. Therefore, it is not possible to test web services using Selenium WebDriver because they are headless.

35. What type of tests have you automated?

We focused on automating test cases of Smoke testing, Sanity testing, and Regression testing. We also automated ‘End to End’ test cases.


Selenium Tutorial for Beginners

Selenium Complete Course Videos

Follow me on social media: