---Advertisement---

Selenium Interview Questions and Answers (Level-1)

By Manisha

Updated On:

---Advertisement---

1. What is Selenium?
Ans: Selenium is a powerful open-source tool used for automating web-based applications. It supports multiple browsers, languages, and platforms.

2. What are the different forms of Selenium?
Ans:

  • Selenium WebDriver – Automates using browser’s native support
  • Selenium IDE – Record and playback Firefox plugin
  • Selenium RC – Deprecated, used JavaScript for automation
  • Selenium Grid – Used for distributed test execution across multiple machines

3. What are the advantages of Selenium?
Ans:

  • Free and open-source
  • Supports many programming languages
  • Cross-browser testing
  • Large community and documentation
  • Non-programmers can use Selenium IDE
  • Selenium Grid supports distributed testing

4. What are the limitations of Selenium?
Ans:

  • Can’t test desktop apps
  • Can’t test APIs or web services
  • Requires coding knowledge
  • Needs external libraries (like TestNG, Log4j, Apache POI)

5. Which browsers are supported by Selenium WebDriver?
Ans:

  • Chrome – ChromeDriver
  • Firefox – FirefoxDriver
  • Internet Explorer – IEDriver
  • Safari – SafariDriver
  • HtmlUnit (Headless) – HtmlUnitDriver
  • Android – Appium/Selendroid
  • iOS – Appium/iOSDriver

6. Can Selenium WebDriver test APIs or Web Services?
Ans: No, because Selenium interacts with browsers, not headless services like APIs.

7. What type of testing can you do using Selenium WebDriver?
Ans: Functional testing and regression testing.

8. What are various element locators in Selenium?
Ans:

  • ID
  • Name
  • Class Name
  • Tag Name
  • XPath
  • CSS Selector
  • Link Text
  • Partial Link Text

9. What is XPath in Selenium?
Ans: XPath (XML Path) is used to navigate through elements and attributes in an XML document. Selenium supports XPath to locate elements in web pages.

10. What is an Absolute XPath?
Ans: XPath starting from the root (html) element, e.g., /html/body/div/div[2]
Disadvantage: Breaks if there is any change in structure.

11. What is a Relative XPath?
Ans: XPath that can start from anywhere in the HTML DOM. Example: //input[@id=’username’]
Advantage: More reliable and flexible.

12. What is the difference between single slash / and double slash // in XPath?
Ans:

  • / – used for absolute paths
  • // – used for relative paths

13. Which XPath is preferred – Absolute or Relative? Why?
Ans: Relative XPath is preferred because it is more robust and less likely to break with UI changes.

14. Difference between Absolute XPath and Relative XPath?
Ans:

  • Absolute starts from root /html
  • Relative starts from any location //input[@type=’text’]

15. How to inspect web element attributes for locating them?
Ans:
Use browser developer tools (F12) or plugins like ChroPath to inspect element attributes (like ID, name, class, etc.).

16. How to locate an element with partial attribute match using XPath?
Ans:
Use contains() method.
Example: //*[contains(@name,’user’)]

17. How to locate an element by its text in XPath?
Ans:
Use text() method.
Example: //*[text()=’Login’]

18. How to select the nth element using XPath?
Ans:

  • div[2] – selects 2nd div
  • div[position()=3] – selects 3rd div

19. What is the syntax for selecting elements by class using CSS Selector?
Ans:
Use .className
Example: .inputtext

20. What is the syntax for selecting elements by ID using CSS Selector?
Ans:
Use #id
Example: #username

The Next 20 Questions-I: SELENIUM

The Next 20 Questions-II: SELENIUM

The Next 20 Questions-III: SELENIUM

---Advertisement---

Leave a Comment