Automation Testing · Selenium

Top 40 Selenium WebDriver Interview Questions & Answers

Top 40 Selenium WebDriver Interview Questions & Answers

1. What is Selenium WebDriver?

  • Selenium Webdriver is an open source test tool
  • Supports cross-browser testing
  • Supports scripting in multiple programming languages
  • Supports platform compatibility
  • Interacts directly with the web browser
  • Supports headless browser testing

Top 40 Selenium WebDriver Interview Questions & Answers2. What are the platforms supported by Selenium Webdriver?

  • Windows
  • Mac OS
  • Linux

3. What are the different browsers supported by Selenium Webdriver

  • Chrome
  • Internet Explorer
  • Safari
  • Firefox
  • Opera
  • HtmlUnit (Headless)
  • PhantomJS (Headless)

Note: Headless browser is a web browser without Graphical User Interface, so one cannot see the test execution on screen. 

4. What are the different programming languages supported by Selenium Webdriver?

  • JAVA
  • C#
  • Ruby
  • Python
  • PHP
  • JavaScript
  • Perl

5. Name any 3 limitations of Selenium WebDriver.

  • Supports only web-based application testing
  • Record and playback option is not available
  • Captcha and barcode readers cannot be tested

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

Locators are used to identify web elements within the webpage. There are 8 different types of locators in Selenium.

  • ID
  • Name
  • ClassName
  • TagName
  • LinkText
  • PartialLinkText
  • CSS Selector
  • XPath

7. What is the command used to launch a browser?

8. What is the command to launch an URL?

9. What is the command used to get the current page URL?

10. What is the command to get the webpage title?

11. What is the command to type values in a textbox?

12. What is the command to get the text values ?

13. What is the command to clear values in a textbox?

14. What is the command to click a control?

15. What is the command to maximize a browser window?

Note: Selenium does not have any built-in function for minimizing the browser window! 

16. What is the command to click on a hyperlink?

17. What is the command to find if an element is displayed on a screen?

18. What is the command to verify if a checkbox/radio is selected?

19. What is the command to verify if a button is enabled?

20. What is the command to verify if a particular text is present on the webpage?

21. What are the different commands used for a dropdown list?

selectByValue

selectByIndex

selectByVisibleText

deselectByValue

deselectByIndex

deselectByVisibleText

deselectAll

22. Name any 4 commonly used Assertions in Selenium?

  • Assert.assertEquals
  • Assert.assertNotEquals
  • Assert.assertTrue
  • Assert.assertFalse

23. What are the different navigation commands?

Note: driver.navigate().to(“www.letzdotesting.com”) and driver.get(“www.letzdotesting.com”) does the same thing! Both are same!!

24. What is the command to right click?

25. What is the command to mouse hover?

26. What is the command to double-click?

27. What is the command used to scroll down to a web element?

28. What is the command to drag and drop?

29. What is the command used to get the attribute values of an element?

30. What is the command used to get the CSS properties of a web element?

31. How to handle alert pop-ups?Alert

32. What is the difference between findElement() and findElements()?

  • findElement() – Finds the first matching element in the DOM & returns a single element.
  • findElements() – Finds all the matching elements in the DOM & returns a list of elements.

Note: findElements() will not throw an exception if an element is not found. It just returns the list size as zero, whereas findElement() will throw element not found exception. 

33. What is the difference between driver.close() and driver.quit()?

  • driver.close() – Used to close current active browser window
  • driver.quit() – Used to close all browser windows

34. What are the two types of waits available in Selenium Webdriver?

  • Implicit Wait – Used to provide default wait between every consecutive test steps. It’s applicable for the entire driver instance. Example below,

  • Explicit Wait – Used to halt the execution for a certain amount of time until certain conditions are met. It’s applicable for a particular instance only. Example below,

35. How to handle iFrames?

36. Name any two testing frameworks that can be integrated with Selenium Webdriver?

  • JUnit
  • TestNG

37. Name any two build management tools that can be integrated with Selenium Webdriver?

  • Gradle
  • Maven

38. What software do you need to run Selenium Webdriver in JAVA?

  • Eclipse or IntelliJ IDE
  • Gradle or Maven build tool
  • Junit or TestNG testing framework
  • Selenium WebDriver library
  • Browser Drivers (Chrome, IE, Safari, Firefox etc.,)

39. Name any advanced framework design that can be used with Selenium Webdriver?

  • Page Object Model
  • Log4j
  • Data-driven testing
  • Dependency Injection (Example: Pico Container)
  • Object Repository

40. Name any 5 Exceptions that you got while working with Selenium Webdriver.

  • ElementNotVisibleException
    • Throws when an element is present on DOM page, but not visible to interact
  • StaleElementReferenceException
    • Throws when an element is not present on DOM page
  • NoAlertPresentException
    • Throws when an alert is not presented on the screen
  • NoSuchAttributeException
    • Throws when an attribute of an element is missing
  • NoSuchElementException
    •  Throws when an element is not found

Thanks for reading 🙂 All the Best!

Suggested Readings : Top 30 Cucumber Interview Questions & Answers

Know anyone who is preparing for Selenium Interview?  Help your friends by sharing this article on Facebook, Twitter, or Google Plus.

Leave a Reply

Your email address will not be published. Required fields are marked *