Selenium 3.5.0-Java : Selenium 3.5.0-Java : Selenium Browser Drivers can't be configured through System Property when referenced through Class Objects -
selenium 3.5.0-java : selenium browser drivers can't configured through system property when referenced through class objects.
environment details
selenium
: 3.5.0
geckodriver
: 0.18.0
mozilla firefox
: 55.0.2
os
: windows 8 pro
usecase
when trying set system property through class method selenium unable find webdriver executable , throws java.lang.illegalstateexception
error message as:
the path driver executable must set webdriver.gecko.driver system property; more information, see https://github.com/mozilla/geckodriver. latest version can downloaded https://github.com/mozilla/geckodriver/releases
code block:
package demo; import org.openqa.selenium.webdriver; import org.openqa.selenium.firefox.firefoxdriver; public class q45756729_pagetitle { webdriver driver; public void title() { system.setproperty("webdriver.firefox.driver","c:\\utility\\browserdrivers\\geckodriver.exe"); driver=new firefoxdriver(); driver.get("https://www.google.co.in"); string titleofthepage=driver.gettitle(); system.out.println(titleofthepage); } public static void main(string[] args) { q45756729_pagetitle obj1=new q45756729_pagetitle(); obj1.title(); } }
exception:
exception in thread "main" java.lang.illegalstateexception: path driver executable must set webdriver.gecko.driver system property; more information, see https://github.com/mozilla/geckodriver. latest version can downloaded https://github.com/mozilla/geckodriver/releases @ com.google.common.base.preconditions.checkstate(preconditions.java:750) @ org.openqa.selenium.remote.service.driverservice.findexecutable(driverservice.java:124) @ org.openqa.selenium.firefox.geckodriverservice.access$100(geckodriverservice.java:41) @ org.openqa.selenium.firefox.geckodriverservice$builder.finddefaultexecutable(geckodriverservice.java:115) @ org.openqa.selenium.remote.service.driverservice$builder.build(driverservice.java:329) @ org.openqa.selenium.firefox.firefoxdriver.toexecutor(firefoxdriver.java:207) @ org.openqa.selenium.firefox.firefoxdriver.<init>(firefoxdriver.java:103) @ org.openqa.selenium.firefox.firefoxdriver.<init>(firefoxdriver.java:99) @ demo.q45756729_pagetitle.tite(q45756729_pagetitle.java:12) @ demo.q45756729_pagetitle.main(q45756729_pagetitle.java:21)
sometime happens:)-
replace this
system.setproperty("webdriver.firefox.driver","c:\\utility\\browserdrivers\\geckodriver.exe");
with
system.setproperty("webdriver.gecko.driver","c:\\utility\\browserdrivers\\geckodriver.exe");
hope helps. thanks.
Comments
Post a Comment