Selenium is a web application testing framework. It does not require scripts writing. It is easy to use. Selenium makes web testing faster. Hence, the skill to use selenium is given preference while selection of a web tester. In this article, we have covered a number of selenium interview questions with answers which would help you in preparing your job interview.
Selenium is a web application testing framework. It is an automated testing tool which requires no knowledge of scripting.
Selenium consists of three major components. These parts are:
- WebDriver and RC
- Selenium IDE
WebDriver allows direct communication of web browser by using its native compatibility for automation. RC component provides APIs for different programming languages like .NET, PHP, Java, NodeJS etc. It is compatible with most of the browsers.
Selenium IDE is an integrated development environment tool to record and playback. It is a firefox plugin. Practically, I have used Selenium IDE on Firefox 50.0 version. However, support for the current version may vary.
You may download Selenium IDE FireFox extension here.
To distribute tests on multiple machines for running tests parallel to save time, grid can be used.
- It is open-source and free to use.
- It has a number of helping communities and material available on internet.
- It supports multiple browsers including Google Chrome and Firefox.
- It supports multiple programming languages including Java, PHP, .NET, Ruby.
- It supports distributed testing.
- It has fresh and regular repository developments.
It is not just an important selenium interview question, but a frequently used function.
A webpage is rendered as elements, sometimes called as HTML tags. There are different identifiers or locators based on which we can select and distinguish an element in web page. These locators or identifiers are:
- Xpath (Used rarely when you are unable to use other identifiers.)
- ID (It is commonly used identifier, even while writing CSS or JS code, we use ID to identify an element. )
- Attribute (We can use various attributes of an HTML tag to identify element.)
- Linktext (We can choose based on text.)
- Name (We can select based on name property of element.)
- CSS (We can select an element based on its CSS properties.)
- Tag (We can use tag names.)
- PartialLink Text (We can use partial link tet to select element.)
There are two kinds of tests which can be supported by selenium before release.
- Functional Testing
- Regression Testing
To verify a state of the application conforms to what is expected, assertion is used.
Selenium has three main kinds of assertions:
Xpath is usually used when application is generating elements dynamically. Otherwise, it is easier to use other identifiers for testing.
It is automated testing.
Automated testing means to create testing scripts and run them. They will keep testing the application. It does not require manual intervention.
No, Selenium supports testing web-based applications only. We can not test mobile applications on selenium.
No, it is not possible to test captcha or barcode with Selenium yet (until date of publishing this article).
No, we cannot generate reports on Selenium directly. However, we can use thrid party tools like JUnit or TestNG to generate reports.
No, selenium does not support bitmap comparison.
Double slash is used to create relative path and starts selection matching everywhere in the document. Whereas single slash is used to create absolute path and starts selection from document node.
- type is used when you need to put some text in the input field. Just like a human enters value.
- typeKeys simulates each keystroke. It is used when a page has some action while you are typing like autosuggest in search fields.
- Verify checks whether the element is on-page or not. Test will not be terminated even element is not present.
- Assert will find an element on-page. If not found, it will stop executing.
To submit a form, use click or element.submit().
To click on particular area on screen clickAt (locator, coordinateString) can be used.
You may launch web browser using WebDriver as:
- WebDriver d = new InternetExplorerDriver();
- WebDriver d = new ChromeDriver();
- WebDriver d = new FirefoxDriver();
These selenium interview questions are very important from an interview preparation point of view. These selenium interview questions list covers commonly asked questions. While you are applying for web testing position, an interviewer never keeps asking questions about one tool. Therefore, along with selenium interview questions, you may have strong command in programming questions as well. You would like to read our article on Computer Science Interview Questions and PHP Interview Questions.