In order to run a test in a browser, that browser must be present on the computer running that test. For example if you have Internet Explorer 9 and you run an Internet Explorer test class, the test will execute in your installed version of Internet Explorer. For browsers like Firefox that allow you to have multiple installations on the same computer, it is possible to specify the exact executable to use as a part of the properties configuration.
This library comes with the Chrome Web Driver used for Chrome on 32-bit Windows, but you can download any one you want from the project website here. To change the web driver in use, you just have to modify the location specified in project and/or build properties file:
@BrowserType(value = Browser.CHROME) public class Form1ChromeTest extends Form1TestBase
This library uses Selenium, which comes with a Firefox web driver already present. You do however have the ability to optionally specify the Firefox executable to use in the in the project and/or build properties:
To specify to run a tests in Firefox use the BrowserType annotation and specify Firefox:
@BrowserType(value = Browser.FIREFOX) public class Form1FirefoxTest extends Form1TestBase
This library uses Selenium, which comes with a Safari web driver already present.
To specify to run a tests in Safari use the BrowserType annotation and specify Safari:
@BrowserType(value = Browser.SAFARI) public class Form1SafariTest extends Form1TestBase
This library comes with the Selenium Web Driver used for Internet Explorer on 32-bit Windows, but you can download any one you want from the project website here. To change the web driver in use, you just have to modify the location specified in project and/or build properties file:
To specify to run a tests in Internet Explorer use the BrowserType annotation and specify Internet Explorer:
@BrowserType(value = Browser.INTERNET_EXPLORER) public class Form1IETest extends Form1TestBase
HtmlUnit is a “GUI-Less browser for Java programs”. It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc… just like you do in your “normal” browser.
There are two ways to specify an HTML Unit test, the first of which is to just specify HTML Unit in the test’s browser annotation:
@BrowserType(value = Browser.HTML_UNIT) public class Form1HtmlUnitTest extends Form1TestBase
The second way is to use a specific browser emulator though HTML Unit, which is done by specifying the browser annotation along with a version:
@BrowserType(value = Browser.HTML_UNIT) @EmulateVersion(value = BrowserVersion.FIREFOX_17) public class Form1HtmlUnitFirefoxTest extends Form1TestBase
The supported emulation versions are the following:
- Chome – CHROME
- Chrome v 16 – CHOME_16
- Firefox v10 – FIREFOX_10
- Firefox v17 – FIREFOX_17
- Firefox v3.6 – FIREFOX_3_6
- Internet Explorer 6 – INTERNET_EXPLORER_6
- Internet Explorer 7 – INTERNET_EXPLORER_7
- Internet Explorer 8 – INTERNET_EXPLORER_8
- Internet Explorer 9 – INTERNET_EXPLORER_9
See Locating Components.