Below are some basic Interview questions for Selenium. These are also commonly asked interview questions, applicable for the job seekers that have less than 2 years of experience in Selenium. Selenium is an API(not a tool that has an IDE like QTP/HP UFT), but it is a robust automation suite that aids in web-based testing and is very popular in the current market now.
Now, let’s look at some basic questions on the same and the answers for the same.
Note: If you need a full set of interview questions that are popularly asked during interviews, look at the book on Amazon with the title: Cracking the popular QA interview questions and answers. It has 135 questions with guideline and example response. It also has the basic refresher on QA concepts.
What is Selenium?
Selenium is an automation suite(a set of API’s) that aid in automation testing of web-based applications across different browsers and platforms. The type of testing performed using Selenium is called Selenium Testing.
How many languages does Selenium Web driver support?
Web Driver supports 6 different languages: Java, C#, Perl, Python, PHP, Ruby
What are the components of Selenium.
Selenium has four major components: Selenium IDE(the first one to come out), Selenium RC, Selenium Web driver, and Selenium Grid(aids in parallel testing)
What is TestNG? Why do we use?
TestNG is a framework like Junit that helps testers organize the tests in a test suite and also produce great test reports in different formats. It uses simple annotations that help the tester perform tests in a particular order or in a suite for both functional and regression testing. It also produces reports in html, xml formats.
What is Eclipse?
Eclipse is an IDE- Integrated Development Environment that helps the Selenium testers write Java code for their automation tests. It customizes the environment by allowing the user select default Java classes and methods. It is also used for other programming languages but using for Java is most popular.
Which IDE have you used in your previous work experience and do you have a preference?
I have used Eclipse IDE with Java programming. There are others like IntelliJ, but I prefer Eclipse and I am comfortable using eclipse as an IDE for my selenium testing.
What is the difference between driver.get() and driver.navigate.to()
Driver.get() will simply take you to the url specified. driver.get(url) will navigate to the url specified. However, driver.navigate.to() has other functionalities: can take the navigation, back, forward or can even refresh a page.
What is the difference between RC and Selenium Webdriver?
What is the difference between implicit wait and explicit wait in Selenium?
Implicit wait when used will just wait for the number of seconds it is asked before a page loads. Explicit wait holds the wait until a condition specified turns true. For example, elementtobeselected(), alertispresent(). When you know the time it takes for the page to load, then implicit wait is sufficient, but in cases where you don’t know the page load time and it varies significantly, then explicitwait() should be used.
How do you check if an element is displayed on a web page.
We have to use isDisplayed() method. It returns a boolean value, so if it is true, the element is displayed on the web page, and if returns false, it is not.
driver.findElement(By.xpath(“xpath of element”)).isDisplayed();
What is Xpath
In Selenium automation, if elements are not found using the common locators like id, name etc, then an XPath is used.XPath is defined as XML path. It is a syntax or language for finding any element on the web page using XML path expression. XPath is used to find the location of any element on a webpage using HTML DOM structure.
XPath syntax: Xpath=//tagname[@attribute=’value’]
How do you check if a button is enabled on a webpage
IsEnabled() method is used to check if a button is enabled on a webpage. The method returns a boolean value, if it returns true, that means the button is enabled, and if it returns false, the button is not enabled on a webpage.
How do you check if a checkbox or radio button is selected
IsSelected() method will help us check if a checkbox or radio button is selected on a web page.
driver.findElement(By.xpath(“xpath of the checkbox/radio button”)).isSelected();
What are some limitations of using Selenium?
Selenium cannot be used in client/server applications. It can only be used for web-based applications.
What is the difference between Assert and Verify
Assert is used to verify the result. If the test case fails then it will stop the execution of the test case there itself and move the control to another test case.
Verify is also used to verify the result. But, if the test case fails then it will not stop executing the test, unlike Assert where it will stop the execution of the test case.
What is the difference b/w close() and quit()?
close() – it will close the browser where the control is.
quit() – it will close all the browsers opened by WebDriver.
What are various ways of locating an element in Selenium
There are 8 types of locators and all are the static methods of the By class.
By.id(), By.name(), By.tagName(), By.className(), By.linkText(), By.partialLinkText(), By.xpath, By.cssSelector().
What is the difference between Single Slash(/) and a Double Slash(//) in Selenium Xpath.
Single Slash is used to identify an immediate child, whereas a Double slash is used to identify the entire structure. A Single Slash is used for Absolute Path and a Double Slash is used for Relative Path in using XPath.
Keep visiting this page for the addition of more questions and the website for content useful for QA career aspirants.