Reputation: 71
I am trying to run Fluentlenium in different browser drivers. I think I need to configure the getDefaultDriver() from Fluentlenium but I am not exactly sure on how to do that. Any exmaple codes would be great. Here is my code and it's not working. The message I am getting in Eclipse is:
"java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list at com.google.common.base.Preconditions.checkState(Preconditions.java:176) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:75) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:107) at com.picklist.tests.PicklistCreate.(PicklistCreate.java:32) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:195) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
"
My Code below:
public WebDriver driver = new ChromeDriver();
// Overrides the default driver
@Override
public WebDriver getDefaultDriver() {
System.setProperty("webdriver.chrome.driver", "C:/chromeDriver/chromedriver.exe"); // Set for ChromeDriver
//return driver;
return driver;
}
If I do the following code, it works but then the driver is no longer defined and I got a ton od code that uses driver.xxx:
// Overrides the default driver
@Override
public WebDriver getDefaultDriver() {
return new ChromeDriver();
}
Upvotes: 3
Views: 3009
Reputation: 10190
There is not getDefaultDriver
in FluentTest, you can use this code:
@Override
public WebDriver newWebDriver() {
System.setProperty("webdriver.chrome.driver", "path-to-chrome-driver/chromedriver");
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("binary", "/usr/bin/chromium-browser");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
return new ChromeDriver(capabilities);
}
Upvotes: 1
Reputation: 71
Here is how I solved this:
public WebDriver driver;
// Overrides the default driver
@Override
public WebDriver getDefaultDriver() {
System.setProperty("webdriver.chrome.driver", "C:/chromeDriver/chromedriver.exe"); // Set for ChromeDriver
driver = new ChromeDriver();
return driver;
}
Upvotes: 3
Reputation: 8396
Have an abstract createDriver()
function that is overridden by each type of driver. Each driver should return a correctly configured driver, which is then stored, and returned when you call getDefaultDriver();
Upvotes: 0