Selenium Java Interview Questions And Answers – Part 8

Selenium Java Interview Questions And Answers – Part 8

Selenium Java Interview Questions and Answers Part-8

1) Define Selenium?

SELENIUM is a free (open-source) automated testing framework used to validate web applications across different browsers and platforms.
You can use multiple programming languages like Java, C#, Python etc to create Selenium Test Scripts.

2) What are the top Selenium alternatives available for free?

– Robot Framework
– Ranorex
– TestComplete
– Tricentis Tosca
– Soap UI

3) What are different versions of Selenium available you have used and what are the additional features you have seen from the previous versions?

Mostly worked with version 3 but now version 4 is going to be released. Following are additional features which are expected in new version:
– Selenium 4 WebDriver is completely W3C Standardized
– The Selenium IDE support for Chrome is available now
– Improved Selenium Grid
– Better Debugging
– Better Documentation

4) What is the principle difference between a Data-driven framework and a Keyword Driven Framework?

Data driven framework includes different test data sources like flat files, databases or XML but Keyword Driven Framework involves business keywords which represent a feature or user actions.

5) What are the two most common practices for automation testing?

– Identify which test cases can be automated and which cannot be automated.
– Do not rely completely on UI Automation.

6) What is Test Driven Development (TDD) Framework?

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the code is improved so that the tests pass.
The following is an sequence of steps which are followed:
– Add a test
– Run all tests and see if it fails
– Write the code
– Run Tests
– Refactor code
– Repeat

7) What is Behavior Driven Development (BDD) Framework?

BDD is a software development process for teams to create simple scenarios on how an application should behave from the end user’s perspective. The goal of implementing BDD testing is to improve collaboration between stakeholders, such as developers, testers, product managers, and business analysts.

8) What are the main traits of a good Software Test Automation framework?

Maintainability, Reliability, Flexibility, Efficiency, Portability, Robustness, and Usability are main attributes of a good automation framework.

9) What are the challenges have you faced with Selenium and how did you overcome them?

– Handling dynamic content: We can use Implicit Wait or Explicit Wait to overcome this challenge
– Handling popup up windows: We can use getWindowHandle and getWindowHandles methods to handle popups.
– Handling alerts: We can use methods provided by Alert interface to handle an alert.
– Handling false positives: We can use different Assertions to look out for false positives.
– Synchronization issues: We can use different wait methods provided by selenium.
– Window based dialogs: We can use AutoIt tool to automate window based dialogs

10) What are the different components of Test Automation Framework?

– Object Repository
– Driver Script
– Test Scripts
– Function Library
– Test data resources

11) What are the benefits does WebDriver have over Selenium RC?

– Webdriver architecture is simpler than RC
– Webdriver is also faster than RC
– WebDriver interacts with page elements in a more realistic way
– WebDriver’s API is simpler than Selenium RC’s
– WebDriver can support the headless HtmlUnit browser but RC cannot

12) Which of the WebDriver APIs is the fastest and why?

HTML Unit Driver is the fastest because it works on a simple HTTP request-response mechanism and doesn’t interact with the browser UI for execution.

13) What is the command to bind a node to Selenium Grid?

driver = new RemoteWebDriver(new URL(nodeURL),capability);

14) Which of Java. C-Sharp or Ruby can we use with Selenium Grid?

All the languages can be used with Selenium Grid.

15) What are Selenium Grid Extras and the additional features does it add to Selenium Grid?

Selenium Grid Extras is a project that helps you set up and manage your local Selenium Grid. Below are the additional features:
– Killing any browser instance by name
– Stopping any Process by PID
– Moving mouse to specific location
– Get Memory usage and disk statistics
– Automatically upgrade WebDriver binaries
– Restart node after a set number of test executions
– Central storage of configurations for all nodes on the HUB server
– Screenshots at the OS level

16) Explain the concept of Object Repository?

An Object Repository is a map between UI element and its locator. It can also be written as an Object Map between UI element and the way to find it.

17) What is the difference between findElement() and findElements(), its return type and few examples of where you have used in Selenium Projects?

findElement returns only first matching element but findElements returns a list of all matching elements.
Return type for findElement is WebElement while for findElements is List<WebElements>
findElements can be used in a scenario where we want to find all broken links in a webpage.

18) Which method can be used to get the text of an element?

We can use getText() method to get text of any element.

19) How to check which check-box from multiple check-box options is selected previously using Selenium?

isSelected() method is used to know whether the Checkbox is toggled on or off.

20) What is the return type of isSelected() method in Selenium?

Return type is boolean.

21) What are the different methods which can be used to verify the existence of an element on a web page?

– driver.findElements(By.xpath(“value”)).size() != 0
– driver.findElement(By.id(id)).isDisplayed()
– driver.findElement(By.id(id)).isEnabled()

22) What is XPath Axes and what are the different Axes available?

XPath axes search different nodes in XML document from current context node. XPath Axes are the methods used to find dynamic elements.
– following: Selects all elements in the document of the current node
– ancestor: The ancestor axis selects all ancestors element (grandparent, parent, etc.) of the current node
– child: Selects all children elements of the current node
– preceding: Select all nodes that come before the current node
– following-sibling: Select the following siblings of the context node.
– parent: Selects the parent of the current node
– descendant: Selects the descendants of the current node

23) How to fetch an element when its attributes are changing frequently?

We can use different XPath methods like contains(), using or/and, starts-with, text(),ends-with

24) What are the different ways to click on a button using Selenium?
– using click() method
– using return key: sendKeys(Keys.Return)
– using JavaScriptExecutor
JavascriptExecutor js = (JavascriptExecutor) driver;
– using Actions class
Actions actions = new Actions(driver);

25) What are the different types of Exceptions in Selenium?

– NoSuchElementException
– NoSuchWindowException
– NoSuchFrameException
– NoAlertPresentException
– InvalidSelectorException
– ElementNotVisibleException
– ElementNotSelectableException
– TimeoutException
– NoSuchSessionException
– StaleElementReferenceException

Next Steps:

> More interview questions and answers on Selenium Java, continue to the next post (Click on Next Post link below)

> Check complete Selenium Java interview questions and answers here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning ?

About Me > Bijan Patel

Connect to me on Linked In (Click here)

On a mission to contribute to the Software Testing Community in all possible ways.

Comments (0)

Leave a Reply

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

For FREE Testing Tutorials & Videos

Open chat
Contact Us on Whatsapp