From reading http://www.scalatest.org/user_guide/using_selenium I’m trying to intergrate selenium & scalatest selenium DSL.
Here is the code I’m using :
class BlogSpec extends FlatSpec with ShouldMatchers with Chrome {
System.setProperty("webdriver.chrome.driver", "C:\\selenium-drivers\\chromedriver.exe");
val host = "http://www.google.com"
go to (host)
title should be ("Awesome Blog")
}
But I receive this error :
* RUN ABORTED * 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:118)
at
org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:61)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:107)
at org.scalatest.selenium.Chrome$class.$init$(WebBrowser.scala:3756)
at BlogSpec.(BlogSpec.scala:12) at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
…
The driver does exist at C:\\selenium-drivers\\chromedriver.exe Am I setting the driver correctly or is there a separate problem in above code ? Chrome is also not starting
I think
System.setPropertyin the above code gets called only after Chrome is instantiated, meaning after the above error is thrown. Maybe you should try setting the system property using-D.