-
Notifications
You must be signed in to change notification settings - Fork 16
Developing with SimpleBrowser.WebDriver
If all works well, developing tests using this driver should not be any different from using other drivers for Selenium WebDriver.
- You can find a lot of information on using WebDriver on http://docs.seleniumhq.org/docs/03_webdriver.jsp
- Make sure you understand the difference between Selenium WebDriver and the older techniques (Selenium RC and the old Selenium scripts, now known as Selenese). Explanation here: http://sqa.stackexchange.com/questions/1580/whats-the-difference-between-selenium-ide-rc-2-and-webdriver
If you are comfortable with WebDriver, it is easy to start using SimpleBrowser through it. You just reference SimpleBrowser.WebDriver and instantiate ie instead of the FirefoxDriver (or whatever browser you now test with). So instead of
IWebDriver browser = new FirefoxDriver();
browser.Navigate().GoToUrl("http://www.funda.nl/koop");
you do
IWebDriver browser = new SimpleBrowserDriver();
browser.Navigate().GoToUrl("http://www.funda.nl/koop");
###Subtle differences SimpleBrowser has no user interface, so does not load any images, CSS stylesheets etc. For the performance this is an advantage, but of course, it comes with disadvantages as well. Oprations like scrolling and tests for visibility mean little to SimpleBrowser.
SimpleBrowser supports no javascript. If the application you work with heavily relies on javascript (which is getting more and more common), SimpleBrowser is not your tool. Look for something else, like PhantomJS (https://github.com/detro/ghostdriver). If javascript is not required, any code that works in Firefox or Chrome using WebDriver should also work in SimpleBrowser. All selectors are supported, as are frames, multiple windows and navigating back and forward.
###Some tricks for debugging
- If you cannot get your code to work, it is useful to test it against a real browser by switching to FirefoxDriver. You might want to have the instantiation of your driver in a central location.
- If something works in Firefox, but not in SimpleBrowser, you can try to do the same thing in Firefox with javascript disabled. Look here how that works: http://stackoverflow.com/questions/3526361/firefoxdriver-how-to-disable-javascript-css-and-make-sendkeys-type-instantly
- Same here for Chrome: https://code.google.com/p/selenium/issues/detail?id=3175#c1
Finally, SimpleBrowser and the driver are not as complete and full-featured as the Firefox and Chrome browsers. We are bound to have missing features and bugs. If you run into one, file an issue, if you know how to fix it, submit a pull request. We are very happy with your feedback.
###Tip: when you need to reference the binaries from a project with another version of WebDriver The downloadable binaries of the SimpleBrowser.WebDriver will normally be compiled against a relatively recent version of WebDriver.dll. As WebDriver.dll is a strongnamed assembly, the reference to one version is completely incompatible with another version. So if your test library is compiled against a different version of the WebDriver assemblies, you will not be able to use the downloaded binaries for the driver. You can either compile the driver from code every time and so compile it against the same version of WebDriver or you can perform this trick in config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebDriver" publicKeyToken="1c2bd1631853048f" culture="neutral" />
<bindingRedirect oldVersion="2.13.0.0" newVersion="2.16.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This will cause the runtime to accept a newer version of the dll in you binaries. In this example you would have downloaded the binaries for the driver compiled against version 2.13 of WebDriver, while your tests are more up-to-date (2.16).