Top 23 Selenium Webdriver Interview Questions You Must Prepare 08.Dec.2023

Sometimes, webdriver cannot launch chrome directly, so (1) we can use Desired Capabilities of WebDriver, put chrome browser application path in the code ; (2) we need to have chromedriver.exe file in the application path. Alternatively, we can manually start chrome driver service, and then launch the test in chrome. 

Selenium 1.0 needs Selenium RC to run a test. However, webdriver can directly launch a browser and run tests. 

When setup a webdriver in the code, we can select InternetExplorerDriver to use ID. If we want to use of the latest and greatest features of the WebDriver "InternetExplorerDriver", we need to download Internet Explorer Server. 

It depends on the format of conversion functionality of Selenium IDE to web driver. sometimes, not all IDE script can be converted to web driver without any problem.  

We can use WebDriverBackedSelenium to run Selenium 1.0 tests in webdriver. 

WebDriver driver = new FirefoxDriver();

Selenium selenium = new WebDriverBackedSelenium(driver, "");

In the setup method, we select FirefoxDriver for the webDriver.

When we have existing tests in Selenium 1.0 (RC), if we want to avoid using Selenium RC, instead we want to use web driver, we need to use web driver backed selenium. 

We can use web driver's back or forward method to simulate browser's navigation button functionality. 

Explicit wait: An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code. The worst case of this is Thread.sleep(), which sets the condition to an exact time period to wait. There are some convenience methods provided that help you write code that will wait only as long as required. WebDriverWait in combination with ExpectedCondition is one way this can be accomplished.

Implicit wait : An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is @Once set, the implicit wait is set for the life of the WebDriver object instance.

In selenium WebDriver, depending on the programming language, I used different test framework. In C#, I used NUnit, and in Java, I used JUnit. In either programming language, I defined browser webdriver in setup method, and wrote test steps in test method and dispose and close the webdriver in the tear down method. 

We can use web driver's windows handler to identify each window and use switch method to pick the window for test. 

We can use Process to invoke application in the code using web driver.

Depending on the programming language, reference files should be added to the test solutions in C# or test projects in Java. For example, in C#, I added webdriver dlls and in Java, I added Selenium-client-driver.jar file. And also, we should have programming IDE like visual studio or eclipse to run webdriver.

Since selenium web driver requires coding skills, QA engineers should have some knowledge of program development in Java, .Net, or other languages. 

Selenium WebDriver libraries can be download from website.

 WebDriver is designed to provide a simpler, more concise programming interface in addition to addressing some limitations in the Selenium-RC API. Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation. 

WebDriver backed Selenium is API that enables running Selenium 1.0 tests in web driver. 

In webdriver, we can use element id, name, css, xpath, link text, partial link text and DOM to locate elements. 

In eclipse, I created java projects and added JUnit or TestNG classes. In the project reference, I added JUnit or TestNG jar file.  In the test class, I used webdriver in setup, test and teardown methods. Sometimes, I used webdriver in beforeclass, beforemethod, aftermethod, afterclass sections.

Selenium WebDriver is very flexible to use with Java, .Net, Python, Ruby or html languages. QA engineers who have good coding skills can use it very effectively. 

We can use WebDriverBackedSelenium to run Selenium 1.0 tests in webdriver. 

WebDriver driver = new FirefoxDriver();

Selenium selenium = new WebDriverBackedSelenium(driver, "");

Any version higher than 2.0 supports webdriver.