Selenium Interview Questions and Answers
Selenium is used for automated testing on web applications, but apart from that it can also automate web-oriented admin tasks and browsers. It is built with strong technical APIs, frameworks, and enhanced automation tools. Selenium is available as open source and launched as a manual testing tool, which later emerged as an automated tool for testing and enables the user to test web-based applications on a wide range of browsers. In this article, the frequently asked interview questions about selenium are discussed in brief.
Top 14 Selenium Interview Questions and Answers
Below are the top question and answers to Selenium. These questions are helpful while giving mock tests or interviews.
Q1. How to differentiate between selenium 2.0 and 3.0?
Answer:
Selenium 2.0 is called as selenium RC, whereas the integrated web driver and selenium RC are called as selenium 3.0.
Q2. Explain famous tools in automation testing.
Answer:
Apart from selenium, business use Rational Robot, IBM rational functional tester, and HP unified functional testing.
Q3. Define automation testing.
Answer:
It is the process where the manual testing of the system under test or application under the test of the web applications is automated. It includes testing tools that help the user to compile test scripts that can be used recurrently without any manual intervention
Q4. How to locate elements in selenium using locators?
Answer:
Locators in selenium are used to search and match the components of the web page which need to interact with. Different variety of selenium locators to find varied web components on the web page are Name, class, Id, XPath, partial link, Link text, and CSS selector.
Q5. Explain types of testing in selenium.
Answer:
On web-based applications, functional testing and regression testing can be used by selenium. Functional testing is used to verify if every function in an application work according to specific needs. It includes black-box testing and not being anxious about source code in the application. Whereas in regression testing, a partial or full selection of the previously executed test codes can be re-executed to check if the existing functions are working fine.
Q6. Explain XPath.
Answer:
When DOM is a standard method to navigate via an HTML element tree, the XPath is navigating tool, that is used to find the web component dependent on the XML path. An extensible markup language is abbreviated as XML, which is used to save, structure, and carry arbitrary data. It also saves the key-value pair that is the same as HTML tags. As both come under the similar category, XPath is also used to find HTML components. The main purpose of locating the components is to transverse different elements from the entire page and helps the user to find the required one taking reference from the other one.
Q7. In XPath, what is the difference between single and double slash?
Answer:
Single slash is used to build an XPath using an absolute path. Here the selection begins from the start node of the document.
Double slash is used to build an XPath using a relative path. Here the selection begins from anywhere in the document.
Q8. Does selenium have technical limitations?
Answer:
The few limitations of selenium are, it cannot be used in a desktop or mobile applications. Barcode readers and captcha cannot be tested using selenium. Third-party tools should be used to generate reports.
Q9. Explain POM.
Answer:
POM is expanded as Page Object Model which is a pattern used to build object repositories using web user interface components. Each web page of the application has a related page class which is responsible to find the web components and execute actions on them. It offers segregated functions and works on a user interface to verify and enhances the readability of code. In test cases, the object repository is independent and the same object repository can be used for multiple testing. It enhances the code’s reusability.
Q10. Explain the difference between getwindowhandle() and getwindowhandles().
Answer:
getwindowhandle() is used to fetch the address of the present browser where it has control and the return type is similar to the string data type.
getwindowhandles() is used to fetch the address of every open browser and executes its data type like Set < string >
Q11. Mention the type of Selenese.
Answer:
The set of commands used to execute a test is called Selenese. Accessors, Actions, and Assertions are types of Selenese.
Actions are used to execute operation and interaction with target components. Ancestors are used to save the value in a variable. Assertions are used as checkpoint.
Q12. What is the difference between driver.quit() and driver.close() commands in selenium?
Answer:
Close() is used to close the present active browser, the is being under use or it closes the recently accessed browser by the web driver. Quit() is used to close all the windows that are opened by the program. But both don’t take any values and accept any values.
Q13. What are navigation commands?
Answer:
Navigate().back() moves the user again to the last-used website by following the browser history.
Navigate().forward() brings the users to a recent web page by following the browser history.
Navigate().Refresh() enables the user to restore the present web page by refreshing all the web elements.
Navigate().to() brings the user to a new window with a new web page based on the given URL.
Q14. How will you find the broken links in WebDriver in selenium?
Answer:
By following the below process, the user can check if the link is valid or broken.
Mount all the links on the web page with anchor tag <a> and for every <a> tag, give attribute ‘href’ to get the hyperlink. Send requests on HTTP for every link and ensure the response code of HTTP. Depending on the HTTP code, define if the link is broken or valid. Use driver.get to move to the corresponding URL that responds to the status of 200 which signifies it is working apart from that all the other status, shows the link is broken. Repeat the same for all the captured links.
Conclusion
Hence selenium has many advantages, such it as open-source, used by a larger community, compatible with cross-browsers like Chrome, Safari, Firefox, etc, applicable to all OS platforms, and supports different programming languages like C#, Perl, Ruby, Python, etc. It also supports distributed testing, and has updated repositories.
Recommended Articles
This is a guide to Selenium Interview Questions. Here we have discussed the top question and answers to prepare for your next interview. You may also look at the following articles to learn more –