Many of you are familiar with Selenium Automation and many of you are also getting your skills updated. In this article, we are going to mention comprehensively the interview questions and answers which you can prepare for Selenium Automation interview. These are designed for beginner and professionals to boost your chances of landing your dream job.
Let’s get started.
Automation testing is a process of automating the manual test process of application under test by using a specific automation tool. In automation tool you create test scripts (we call test cases ‘scripts’ in terms of automation) and execute them repeatedly without any manual intervention.
Benefits of automation testing are many:
Selenium is one of the top Automation testing tools available in the market. Selenium is a suite which is designed to support automation of functional testing of web based applications on a wide range of browsers and various platforms. It supports multiple programming languages as well. Selenium is open source and has an existence of large community, due to this reason it has become one of the most accepted automation tool among the professionals.
Selenium suite has four different components or forms:
They are called as locators. They are the address of web elements which identify them uniquely within the webpage. We have different locators to find web element precisely:
We have to use the locators with their specified order as shown below:
Both are used for validation in Selenium. Asserts command check whether the condition is true or false. For example, we are trying to locate the element in the web page and assert command will check whether that element is present or not. Program will execute the next step if the condition is true, otherwise the execution will stop and no further testing is possible. Whereas in verify command, it works the same way as asserts, but it continues to execute irrespective of the conditions being true or false and all the steps will be executed.
In explicit wait, we make the web driver wait for the specific element for the given time. E.g. we can give command to web driver to wait for the given web element for 5 seconds and for another web element for 10 seconds. Whereas in implicit wait, we make the web driver wait for the same given time for all the web elements present within the web page. E.g. if we set implicit wait of 5 seconds then it will be applicable to all the web elements present within the web page.
It is a powerful way to parse any HTML code of a web page. XPath is a query language for selecting nodes from XML documents. When you don’t have suitable name or id attribute to locate the element then you have to use XPath.
In absolute XPath, we locate element by using an XML expression beginning from the root node. We have to specify complete path while using absolute XPath expression. There is a single main disadvantage in that, if even the slightest of change happens in any element then whole absolute XPath fails. Whereas in relative XPath, we provide direct path to the reach the element.
Whenever a simple change occurs in the element our absolute XPath fails to locate. While Relative XPath is not affected by these simple changes due to the fact that it provides direct path to reach those elements. Therefore it is recommended to use Relative XPath over Absolute XPath.
Firepath is the name of that add-on. Just by inspecting the element in the webpage one can auto-generate XPath expressions and CSS Selectors for their automation scripts.
The fundamental difference is that in XPath expressions we can traverse back in the web page i.e. we can move to parent elements from their child elements. Where in CSS Selectors, we can only move forward in the web page i.e. we cannot locate child from their parents.
You can launch browsers by creating an instance of driver of a particular browser:
In selenium, driver.close() method is used to close the window of the web browser which is currently in used or working for testing purpose. In this command, there is no need to provide parameters. Whereas driver.quit() command closes down all the windows of the web browser which the script has opened. Similar to driver.close() command, this command do not require any parameter.
No. There is no difference between those two commands, both are used to navigate to a URL specified in the command or passed as a parameter.
We use Selenium Grid when we need to execute test scripts simultaneously on various platforms and browsers to achieve the distributed test execution and to perform testing on the different environment and ultimately saving the time.
Write a comment