简体   繁体   中英

Check if FirefoxDriver or ChromeDriver is installed via system properties?

I have a set of web tests that run in various browsers. I want to skip a test if the corresponding driver isn't installed.

However, these tests that will be executed by different machines,meaning OS and driver setups will differ. I was wondering if there was some way to use JUnit.assumeNotNull() to check if the system propery values for the driver are not null?

For instance:

@Before
public void checkForDriver() {
    assumeNotNull(System.getProperty("webdriver.chrome.driver"));
}

or

@Before
public void setupCheck() {        
    assumeNotNull(System.getProperty("webdriver.safari.driver"));
}

This works for chrome and others, but for firefox I've been checking both "webdriver.firefox.bin" and "webdriver.firefox.driver" and the test still skips. I know that firefoxDriver should be working fine(the test runs and passes if i remove the assumption).

Any advice or another good method to check that a driver/browser is installed?

In order to run Selenium with IE or Chrome, you need to install some extra binary on your test client machine. In contrast, FirefoxDriver is an integral part of Selenium. So if you run Selenium, a test whether FirefoxDriver is installed does not really make sense.

In case Firefox as a browser is not installed on your test client machine, you should probe for Firefox browser sytem properties, as opposed to FirefoxDriver .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM