One of our counsellors will get in touch with you soon!
One of our counsellors will get in touch with you soon!
We all know that job interviews can be challenging especially if you don’t have all the information in one place. Moreover, preparing for an interview takes a lot more than Googling a list of common interview questions.
But don’t worry we have chalked down some Selenium interview questions and answers that can save your time and efforts.
Also, in case if you are looking to get hired for Selenium Automation Testing, then you should have the following skills:
Let’s start with the basics and then we will step the ladder higher. We have tried to cover selenium java interview questions and selenium testing interview questions also.
Selenium IDE- It is a tool for recording and playing back. You can also call it a firefox plugin.
Selenium Grid- It is the best way to run parallel testing on multiple machines. The grid helps you in distributing tests while making sure that you save time in performing them on running in-browser test suites.
Selenium RC and WebDriver – It is a server that allows users to create test scripts in a desirable programming language like Java, .NET, PHP, etc. Also, remember that with most of the browsers Webdriver and RC work.
Though both assert and verify commands checks whether the given condition is true or false. But one of the basic differences between the two lies after the condition checking is complete.
For instance, if a particular condition comes out to be false in the case of an assert, then the execution stops there only, and no further tests will be done. But if the condition is true then the program control will move to the next test step.
Whereas on the other hand Verify command, does not care about the result of the condition checking. Whether it is true or false, the program will be completed.
There are different ways to find an element in a web page using Selenium:
Testing types that can be supported by Selenium are as follows:
The syntax used for launching any browser like Google Chrome, Mozilla Firefox, and Internet Explorer using WebDriver is:
new WebDriver driverDriver();
With the help of WebDriver we can easily find out any element on the screen. And we can do this with the following 3 methods:
The four parameters that you have to pass in Selenium are:
With the help of the Webdriver software testing tool, one can easily submit any form. Just type element.submit(); or you can use click() method to click on any button of the software web application.
Type keys Simulates keystroke events on the specified element, as though you typed the value key-by-key.
Type command is mainly used to type text into the text box and text area fields. Type command forces the specified value into the page directly.
This command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect. For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in the field.
findElement method is used to access a single web element on a page. It returns the first matching element. It throws a NoSuchElementException exception when it fails to find If the element.
findElements method returns the list of all matching elements. This method returns an empty list when the element is not available or doesn’t exist on the page. It doesn’t throw NoSuchElementException.
JUnit is a Java-based, open-source framework to help you execute unit testing. JUnit is used primarily to test each and every unit or component of your application like classes and methods. It helps to write and run repeatable automated tests, to ensure your code runs as intended. The framework offers support to Selenium for automation testing web-apps or websites.
@BeforeClass: This annotation is used to initialize any object that we use in our running test case. Used to execute some statements before all the test cases mentioned in the script.
@Before: This annotation is used whenever we want to initialize an object for the time the method is being used. This annotation is usually used for setting up the test environment.
@Test: This annotation tells JUnit that the public void method() to which it is attached can be run as a test case. This annotation includes the test method for an application that you want to test.
@After: The initialization done in the @Before annotation method should be released in the @After annotation method. So, this annotation is executed every time after each test method. The primary purpose of @After annotation is to teardown. The teardown is a process of deleting temporary data.
@AfterClass: The initialization done in the @BeforeClass annotation method should be released in the @AfterClass annotation method. So, this annotation is executed once but it will be executed after all tests have finished executing.
@Ignore: This annotation tells JUnit that this method shall not be executed. In scenarios, where our code module is not ready in a particular test case, we can temporarily put that code module in the @Ignore annotation method to avoid test case failure.
POM is a design pattern used for enhancing test maintenance and reducing code duplication.
A page object is an object-oriented class that serves as an interface to a page of your application under test. The tests then use the methods of this page object class whenever they need to interact with the User Interface (UI) of that page.
The benefit is that if the UI changes for the page, the tests themselves don’t need to change, only the code within the page object needs to change. Subsequently, all changes to support that new UI are in a single place.
Advantages of the Page Object Model Framework:
Page Object is a class that represents a web page and holds the functionality and members. Page Object Model is a way of representing an application in a test framework. For every page in the application, we create a Page Object to reference the page.
Page Factory is a way to initialize the web elements you want to interact with within the page object when you create an instance of it. Page Factory is one way of implementing the Page Object Model.
Implicit wait: Directs the WebDriver to wait for a certain measure of time before throwing an exception. Once this time is set, WebDriver will wait for the element before the exception occurs.
Explicit Wait: The WebDriver is directed to wait until a certain condition occurs before proceeding with executing the code. It is important in cases where there are certain elements that naturally take more time to load.
WebDriver allows handling web-based pop-ups via the Alert interface. The general syntax is:
Alert alert = driver.switchTo().alert();
A total of 4 methods are available for handling the web-based pop-ups, namely:
Screenshot can be taken using the TakeScreenshot function.
By using the getScreenshotAs() method you can save that screenshot.
Example: File scrFile = ((TakeScreenshot)driver).getScreenshotAs(outputType.FILE);
Single Slash “/” – Single slash is used to create XPath with absolute path i.e. the XPath would be created to start selection from the document node/start node.
Double Slash “//” – Double slash is used to create XPath with a relative path i.e. the XPath would be created to start selection from anywhere within the document.
Below are some parameters listing the differences between Selenium and QTP
A Robot class in Selenium is used to generate input events for test automation, self-running demos, and other applications where you need control over the mouse and keyboard.
WebDriver cannot handle OS pop-ups, so in Java 1.3, the Robot class was introduced. The primary purpose of this Robot class is to facilitate automated testing for Java platform implementations and to provide control over mouse and keyboard devices.
27 FEB 2019RACI Matrix: How does it help Project Managers?