Selenium - Web Driver Interview Questions

  1. Selenium 2.0? I have heard this buzz word many times.
  2. Answer: Selenium 2.0 is a consolidation of two web testing tools:
    • Selenium RC and
    • Web Driver,
    It claims to give best of both words: Selenium and Web Driver.
  3. Why are two tools being combined as Selenium 2.0?
  4. Answer: Selenium 2.0 promises to give much cleaner API than Selenium RC and at the same time not being restricted by JavaScript Security restriction like same origin policy.
  5. So everyone is going to use Selenium 2.0?
  6. Answer: Well no, for example if you are using Selenium Perl client driver than there is no similar offering from Selenium 2.0 and you would have to stick to Selenium 1.0 till there is similar library available for Selenium 2.0
  7. So how do I specify my browser configurations with Selenium 2.0?
  8. Answer: Selenium 2.0 offers following browser/mobile configuration:
    • Android Driver,
    • Chrome Driver,
    • EventFiringWebDriver,
    • Firefox Driver,
    • HtmlUnitDriver,
    • InternetExplorerDriver,
    • IPhoneDriver,
    • IPhoneSimulatorDriver,
    • RemoteWebDriver
    And all of them have been implemented from interface WebDriver.To be able to use any of these drivers, you need to instantiate their corresponding classes.
  9. How is Selenium 2.0 configuration different from Selenium 1.0?
  10. Answer: In case of Selenium 1.0, you need Selenium jar file pertaining to one library; for example, in case of Java you need Java client driver and also Selenium server jar file. With Selenium 2.0, you need language Binding (i.e. Java, C#, etc) and Selenium server jar if you are using Remote Control or Remote Web Driver.
  11. Selenium Benefits over Web Driver.
  12. Selenium supports many browsers and many languages, Web Driver needs native implementations for each new language/browser combo. Very mature and complete API Currently (Sept 2010) supports JavaScript alerts and confirms better Benefits of Web Driver Compared to Selenium
    • Native automation faster and a little less prone to error and browser configuration
    • Does not Requires Selenium-RC Server to be running
    • Access to headlessHTMLUnit can allow really fast tests
    • Great API

  13. What is Web Driver?
  14. Web Driver uses a different underlying framework from Selenium’s javascript Selenium-Core. It also provides an alternative API with functionality not supported in Selenium-RC. WebDriver does not depend on a JavaScript core embedded within the browser; therefore it is able to avoid some long-running Selenium limitations. WebDriver’s goal is to provide an API that establishes A well-designed standard programming interface for web-app testing.
    • Improved consistency between browsers.
    • Additional functionality addressing testing problems not well-supported in Selenium 1.0.
    The Selenium developers strive to continuously improve Selenium. Integrating WebDriver is another step in that process. The developers of Selenium and of WebDriver felt they could make significant gains for the Open Source test automation community be combining forces and merging their ideas and technologies. Integrating WebDriver into Selenium is the current result of those efforts.
  15. When to Use WebDriver?
  16. One should use WebDriver when requiring improved support for
    • Mult-browser testing including improved functionality for browsers not well-supported by Selenium-1.0.
    • Handling multiple frames, multiple browser windows, popups, and alerts.
    • Page navigation.
    • Drag-and-drop.
    • AJAX-based UI elements.
  17. Advantages of web driver compared to selenium.
    • Support for iPhone and Android testing
    • Implementation of listeners - a much awaited feature
    • Better features for Ajax testing.
    • You can easily simulate clicking on front and back button of browser.
    • You can extract objects in bulk like QTP. For ex - extract all links of page. With RC this was a big hastle
    • Unlike RC you don’t have to start a server in webdriver.
    • You can simulate movement of a mouse using selenium.
    • Tabs and pops are more or less the same. RC can also handle and Webdriver can also handle.
    • You can find coordinates of any object using Webdriver.
    • You have classes in Webdriver which help you to simulate key press events of keyboard.
    • Keyword driven framework is very easy to build in webdriver.