Software testers who are planning to get a testing or test automation job should read this post. We’ve compiled the best 35 Selenium Webdriver questions to help you succeed in a job interview. You’ll find a short and concise answer for all the Selenium Webdriver questions as most of the interviewers expect from an ideal candidate. There has been a lot of efforts involved in preparing the perfect set of interview questions.
We believe that this questionnaire will not only benefit you in face-to-face interviews also in telephonic ones as well. It has been quite popular these days as the IT companies want to make sure the technical skills of a candidate before they invite him for a one to one discussion. Also, no interviewer would ask merely the conceptual or theoretical questions; they would want to test you a bit deeper by putting up tricky questions about the technology. That’s where the list of these 35 Selenium Webdriver questions is going to help you as a supplement for cracking the interview. The readers who are interested in detailed articles may go through the core Selenium Webdriver concepts section from our blog.
In addition to this post, you should also check out the most read post on this blog which exclusively covers the core Selenium interview questions and answers for beginners and experienced. It’ll make sure that you’ve sufficient understanding of the Selenium Webdriver concepts.
35 Selenium Webdriver Questions to Succeed in a Job Interview.
Let’s quickly go through the list of the top Selenium Webdriver questions specially designed for testing job seekers.
Core Concept Related Selenium Webdriver Questions.
Q: How many types of Webdriver APIs are available in Selenium?
Below is the list of driver classes that you can use for the browser automation.
Q: How would you make sure that a page is loaded using Selenium and Webdriver?
In Selenium, you can use the below lines of code to check for the successful loading of a web page. The best approach is by selecting an element from the page & stand by till it becomes clickable.
Below is the Webdriver specific code to achieve the same objective.
Q: How to launch a batch file in a Selenium Webdriver project?
It's usual in a test suite to run a batch file or an executable file for setting up the pre-requisites before starting the automation. You can use the below Java code for this purpose.
Q: How to run the selenium IDE test suite from the command line?
We've given the command to run the SIDE test suite in the next line.
Q: How to run the Selenium Webdriver test from the command line?
We can run any Selenium Webdriver test written in Java using the following command.
Q: What are the different exceptions you face in Selenium Webdriver?
Q: How would you automatically click a screenshot whenever any exception occurs?
For this you will have to use <EventFiringWebDriver> class and needs to implement the <onException> method of the <WebDriverEventListener> interface. See the code example given below.
Q: How would you select any particular text using the Selenium Webdriver?
It seems an easy one at first but you need to do a little more to achieve this.
Q: Give an example to perform drag and drop action In Selenium WebDriver?
Yes, we can use the Advanced User Interactions API to perform drag and drop operations in a Selenium Webdriver project.
Q: How would you fill a text field without calling the sendKeys()?
It's a bit slower than the sendKeys() method but we do have means to type in a text field. See the Java code given below.
Q: How can you check the state of a checkbox/radio button?
We can call the isSelected() method to test the status of these elements.
Q: How would you handle the alert popups in Selenium Webdriver?
First, you’ve to switch the control to the pop up then press the ok or cancel button. After that, turn back to the source page screen.
Q: What is the process to start the IE/Chrome browser?
If you want to start a browser then, just set the system properties as mentioned below.
Q: How would you simulate the right click operation in WebDriver?
You can make use of the Actions class features.
Q: How would you select a menu item from a drop down menu?
There can be following two situations.
- If the menu has is using the <select> tag then you can call the <selectByValue()> or <selectByIndex()> or <selectByVisibleText()> methods of the Select class.
- If the menu doesn’t use the <select> tag then simply find the XPath of that element and perform the click action for its selection.
Q: What is the FirefoxDriver, class or an interface? And which interface does it implement?
FirefoxDriver is a Java class, and it implements the <WebDriver> interface. It contains the implementations of all the methods available in the <WebDriver> interface.
Q: What is the name of the super interface of the Webdriver?
Q: What is the main difference between the close() and quit() methods?
Q: What is the best way to check for the highlighted text on a web page?
Use the below code to verify the highlighted text for an element on the web page.
Q: What is the Selenese command to show the value of a variable in the log file?
CSS/XPath Related Selenium Webdriver Questions.
Q: How would you differentiate between the absolute and relative XPath?
Single slash "/" signifies an absolute XPath.
Double Slash "//" represents the relative XPath.
Q: What are the different ways to find the element by CSS class?
Say, the name of the CSS class is <MyTest>. Then the most-simple way to find the element is as follows.
If you want an exact comparision to avoid matching texts like “OhhMyTest” or “MyTesting” then use this.
You can even use the <normalize-space> function to remove any leading or trailing whitespaces.
Q: How to specify a child element using XPath?
Q: How to specify a child element using CSS?
Q: How to identify a sub child element using XPath?
Q: How to identify a sub child element using CSS?
Q: How do you access an element ID using CSS?
Q: How would you get to the next sibling?
You may try this code.
Or you can use the below code.
TestNG Selenium Webdriver Questions.
Q: What is the time-unit you use in testng time tests?
We use milliseconds as the time unit in @Test or @TestSuite methods.
Q: What is the use of priority in @Test methods and how do you set it?
We define the priority in @Test annotated methods to set the order of test execution. Please check the below example.
The above test will run in the following order.
Q: What are the two different ways of generating reports in TestNG?
There are two ways to produce a report with Test NG, they are
- Use of Listeners: You can implement the <org.testng.ITestListener> interface and its methods. Reporting will start when the test begins, finishes, skips, passes or fails.
- Use of Reporters: Another way to enable reporting is by implementing the <org.testng.Reporter> interface. Unlike the listener interface, here the reporting begins after the whole test suite reaches to the end. The reporting class receives the object which contains the information of the whole test run.
Q: How to execute the testng test suite from the command line?
We don't always need to open Eclipse to run the TestNG project, try using the below command instead.
Q: How to turn off the test-output (generated test output folder) in TestNG?
In Eclipse, modify the launch/Run configuration and add a <-usedefaultlisteners false> option to disable the test output.
Let’s now summarize the above post which includes the top 35 Selenium Webdriver questions and do a quick review of the content.
We’ve tried to bring the most pertinent Selenium Webdriver questions in this post, but this topic belongs to an evolving subject. Hence, there would always be the scope of improvements and enhancements. We’ll keep supporting all the new changes in the Selenium Webdriver technology and will add more and more questions that could add to your skills and boost your confidence while you face any job interview.
We’ve already covered a wide range of Selenium interview questions and quizzes on our blog, and this post is like a testimonial that we do introduce a fresh set of questions on a regular basis.
Next, we like you to contribute to our knowledge drive. You can do this by sharing this list of top Selenium Webdriver questions among your friends and on social media using the sharing icons shown below.
All the Very Best,