Selenium - Running ChromeDriver Without Modifying PATH
up vote
2
down vote
favorite
I am attempting to make a simple framework using Selenium for Java. One of the unfortunate aspects of trying to set this up has been that I don't have access to edit the SYSTEM level variables on my Windows machine.
In attempting to run a single JUnit test that is merely trying to go to a website, and then assert it's on the page I pointed it at, I keep receiving an error that the path to the ChromeDriver executable must be set. I do have this downloaded locally.
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Now, I can avoid that error by just throwing a System.setProperty("webdriver.chrome.driver", "/path/to/myexecutable.exe")
in a class within the main entry point of a program, but not sure how to get around this with using a unit test.
My basic test:
package com.mytestpackage;
import org.junit.Assert;
import org.junit.Test;
public class UnitTest {
@Test
public void canGoToHomePage() {
Pages.homePage().goTo();
Assert.assertTrue(Pages.homePage().isAt());
}
}
And my three simple classes - Browser, HomePage, and Pages:
Browser
package com.mytestpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Browser {
static WebDriver driver = new ChromeDriver();
public static void goTo(String url) {
driver.get(url);
}
public static String title() {
return driver.getTitle();
}
}
HomePage
package com.mytestpackage;
public class HomePage {
static String url = "http://test.salesforce.com";
static String title = "Login | Salesforce";
public void goTo() {
Browser.goTo(url);
}
public boolean isAt() {
return Browser.title().equals(title);
}
}
Pages
package com.mytestpackage;
public class Pages {
public static HomePage homePage() {
return new HomePage();
}
}
The main point of frustration is not being able to edit the system variables. Any hackaround/workaround suggestions would be greatly appreciated.
java selenium selenium-webdriver selenium-chromedriver
add a comment |
up vote
2
down vote
favorite
I am attempting to make a simple framework using Selenium for Java. One of the unfortunate aspects of trying to set this up has been that I don't have access to edit the SYSTEM level variables on my Windows machine.
In attempting to run a single JUnit test that is merely trying to go to a website, and then assert it's on the page I pointed it at, I keep receiving an error that the path to the ChromeDriver executable must be set. I do have this downloaded locally.
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Now, I can avoid that error by just throwing a System.setProperty("webdriver.chrome.driver", "/path/to/myexecutable.exe")
in a class within the main entry point of a program, but not sure how to get around this with using a unit test.
My basic test:
package com.mytestpackage;
import org.junit.Assert;
import org.junit.Test;
public class UnitTest {
@Test
public void canGoToHomePage() {
Pages.homePage().goTo();
Assert.assertTrue(Pages.homePage().isAt());
}
}
And my three simple classes - Browser, HomePage, and Pages:
Browser
package com.mytestpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Browser {
static WebDriver driver = new ChromeDriver();
public static void goTo(String url) {
driver.get(url);
}
public static String title() {
return driver.getTitle();
}
}
HomePage
package com.mytestpackage;
public class HomePage {
static String url = "http://test.salesforce.com";
static String title = "Login | Salesforce";
public void goTo() {
Browser.goTo(url);
}
public boolean isAt() {
return Browser.title().equals(title);
}
}
Pages
package com.mytestpackage;
public class Pages {
public static HomePage homePage() {
return new HomePage();
}
}
The main point of frustration is not being able to edit the system variables. Any hackaround/workaround suggestions would be greatly appreciated.
java selenium selenium-webdriver selenium-chromedriver
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am attempting to make a simple framework using Selenium for Java. One of the unfortunate aspects of trying to set this up has been that I don't have access to edit the SYSTEM level variables on my Windows machine.
In attempting to run a single JUnit test that is merely trying to go to a website, and then assert it's on the page I pointed it at, I keep receiving an error that the path to the ChromeDriver executable must be set. I do have this downloaded locally.
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Now, I can avoid that error by just throwing a System.setProperty("webdriver.chrome.driver", "/path/to/myexecutable.exe")
in a class within the main entry point of a program, but not sure how to get around this with using a unit test.
My basic test:
package com.mytestpackage;
import org.junit.Assert;
import org.junit.Test;
public class UnitTest {
@Test
public void canGoToHomePage() {
Pages.homePage().goTo();
Assert.assertTrue(Pages.homePage().isAt());
}
}
And my three simple classes - Browser, HomePage, and Pages:
Browser
package com.mytestpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Browser {
static WebDriver driver = new ChromeDriver();
public static void goTo(String url) {
driver.get(url);
}
public static String title() {
return driver.getTitle();
}
}
HomePage
package com.mytestpackage;
public class HomePage {
static String url = "http://test.salesforce.com";
static String title = "Login | Salesforce";
public void goTo() {
Browser.goTo(url);
}
public boolean isAt() {
return Browser.title().equals(title);
}
}
Pages
package com.mytestpackage;
public class Pages {
public static HomePage homePage() {
return new HomePage();
}
}
The main point of frustration is not being able to edit the system variables. Any hackaround/workaround suggestions would be greatly appreciated.
java selenium selenium-webdriver selenium-chromedriver
I am attempting to make a simple framework using Selenium for Java. One of the unfortunate aspects of trying to set this up has been that I don't have access to edit the SYSTEM level variables on my Windows machine.
In attempting to run a single JUnit test that is merely trying to go to a website, and then assert it's on the page I pointed it at, I keep receiving an error that the path to the ChromeDriver executable must be set. I do have this downloaded locally.
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Now, I can avoid that error by just throwing a System.setProperty("webdriver.chrome.driver", "/path/to/myexecutable.exe")
in a class within the main entry point of a program, but not sure how to get around this with using a unit test.
My basic test:
package com.mytestpackage;
import org.junit.Assert;
import org.junit.Test;
public class UnitTest {
@Test
public void canGoToHomePage() {
Pages.homePage().goTo();
Assert.assertTrue(Pages.homePage().isAt());
}
}
And my three simple classes - Browser, HomePage, and Pages:
Browser
package com.mytestpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Browser {
static WebDriver driver = new ChromeDriver();
public static void goTo(String url) {
driver.get(url);
}
public static String title() {
return driver.getTitle();
}
}
HomePage
package com.mytestpackage;
public class HomePage {
static String url = "http://test.salesforce.com";
static String title = "Login | Salesforce";
public void goTo() {
Browser.goTo(url);
}
public boolean isAt() {
return Browser.title().equals(title);
}
}
Pages
package com.mytestpackage;
public class Pages {
public static HomePage homePage() {
return new HomePage();
}
}
The main point of frustration is not being able to edit the system variables. Any hackaround/workaround suggestions would be greatly appreciated.
java selenium selenium-webdriver selenium-chromedriver
java selenium selenium-webdriver selenium-chromedriver
asked 2 days ago
trebleCode
539414
539414
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
It seems that the problem you see is solved by WebDriverManager - official docs
We are using it in our framework, and it makes all users free from carrying about system properties and versions of a chromedriver. (When you use executable of a chromedriver you will need to be sure to keep it updated with the browser updates as well)
Add the following method to your test class:
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
And don't forget to attach a dependency to WebDriverManager in your pom.xml (Java 8 or upper required):
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
... or in Gradle project:
dependencies {
testCompile("io.github.bonigarcia:webdrivermanager:3.0.0")
}
Important sidenote: remove 'static' from your WebDriver field declaration in a Browser class. Keeping static will not allow you do proceed with parallel tests execution.
Thanks @Vladimir Efimov. This resulted in errors with slf4j initially. I'm still trying to work through them. I'm also behind a corporate proxy so am likley going to have to do some further customizations. Thanks for pointing this out though, it will likely be very helpful.
– trebleCode
2 days ago
Unfortunately for me, my company is blocking me getting to chromedriver.storage.googleapis.com which that repository tries to reach out to to forcibly download, so that option is dead in the water for me :( However I'm not blocked from the mirror listed for chrome, so that may work! npm.taobao.org/mirrors/chromedriver
– trebleCode
2 days ago
1
If you've arrived here from the future with Google, adding the above dependencies did fix, however there were some additional steps. Create a file called 'log4j.properties' somewhere in your project, and point the configuration class path to the log4j config file. See: stackoverflow.com/questions/7421612/… and stackoverflow.com/questions/12532339/…
– trebleCode
2 days ago
1
Of note, my call in the@BeforeClass setupClass()
looked like:WebDriverManager.chromedriver().proxy("mycompanyproxy.site.com:1234").useMirror().setup();
TheuseMirror()
option works but it cycles through all the versions it finds and chooses an option, which causes some delays but hey it works!
– trebleCode
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
It seems that the problem you see is solved by WebDriverManager - official docs
We are using it in our framework, and it makes all users free from carrying about system properties and versions of a chromedriver. (When you use executable of a chromedriver you will need to be sure to keep it updated with the browser updates as well)
Add the following method to your test class:
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
And don't forget to attach a dependency to WebDriverManager in your pom.xml (Java 8 or upper required):
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
... or in Gradle project:
dependencies {
testCompile("io.github.bonigarcia:webdrivermanager:3.0.0")
}
Important sidenote: remove 'static' from your WebDriver field declaration in a Browser class. Keeping static will not allow you do proceed with parallel tests execution.
Thanks @Vladimir Efimov. This resulted in errors with slf4j initially. I'm still trying to work through them. I'm also behind a corporate proxy so am likley going to have to do some further customizations. Thanks for pointing this out though, it will likely be very helpful.
– trebleCode
2 days ago
Unfortunately for me, my company is blocking me getting to chromedriver.storage.googleapis.com which that repository tries to reach out to to forcibly download, so that option is dead in the water for me :( However I'm not blocked from the mirror listed for chrome, so that may work! npm.taobao.org/mirrors/chromedriver
– trebleCode
2 days ago
1
If you've arrived here from the future with Google, adding the above dependencies did fix, however there were some additional steps. Create a file called 'log4j.properties' somewhere in your project, and point the configuration class path to the log4j config file. See: stackoverflow.com/questions/7421612/… and stackoverflow.com/questions/12532339/…
– trebleCode
2 days ago
1
Of note, my call in the@BeforeClass setupClass()
looked like:WebDriverManager.chromedriver().proxy("mycompanyproxy.site.com:1234").useMirror().setup();
TheuseMirror()
option works but it cycles through all the versions it finds and chooses an option, which causes some delays but hey it works!
– trebleCode
2 days ago
add a comment |
up vote
3
down vote
accepted
It seems that the problem you see is solved by WebDriverManager - official docs
We are using it in our framework, and it makes all users free from carrying about system properties and versions of a chromedriver. (When you use executable of a chromedriver you will need to be sure to keep it updated with the browser updates as well)
Add the following method to your test class:
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
And don't forget to attach a dependency to WebDriverManager in your pom.xml (Java 8 or upper required):
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
... or in Gradle project:
dependencies {
testCompile("io.github.bonigarcia:webdrivermanager:3.0.0")
}
Important sidenote: remove 'static' from your WebDriver field declaration in a Browser class. Keeping static will not allow you do proceed with parallel tests execution.
Thanks @Vladimir Efimov. This resulted in errors with slf4j initially. I'm still trying to work through them. I'm also behind a corporate proxy so am likley going to have to do some further customizations. Thanks for pointing this out though, it will likely be very helpful.
– trebleCode
2 days ago
Unfortunately for me, my company is blocking me getting to chromedriver.storage.googleapis.com which that repository tries to reach out to to forcibly download, so that option is dead in the water for me :( However I'm not blocked from the mirror listed for chrome, so that may work! npm.taobao.org/mirrors/chromedriver
– trebleCode
2 days ago
1
If you've arrived here from the future with Google, adding the above dependencies did fix, however there were some additional steps. Create a file called 'log4j.properties' somewhere in your project, and point the configuration class path to the log4j config file. See: stackoverflow.com/questions/7421612/… and stackoverflow.com/questions/12532339/…
– trebleCode
2 days ago
1
Of note, my call in the@BeforeClass setupClass()
looked like:WebDriverManager.chromedriver().proxy("mycompanyproxy.site.com:1234").useMirror().setup();
TheuseMirror()
option works but it cycles through all the versions it finds and chooses an option, which causes some delays but hey it works!
– trebleCode
2 days ago
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
It seems that the problem you see is solved by WebDriverManager - official docs
We are using it in our framework, and it makes all users free from carrying about system properties and versions of a chromedriver. (When you use executable of a chromedriver you will need to be sure to keep it updated with the browser updates as well)
Add the following method to your test class:
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
And don't forget to attach a dependency to WebDriverManager in your pom.xml (Java 8 or upper required):
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
... or in Gradle project:
dependencies {
testCompile("io.github.bonigarcia:webdrivermanager:3.0.0")
}
Important sidenote: remove 'static' from your WebDriver field declaration in a Browser class. Keeping static will not allow you do proceed with parallel tests execution.
It seems that the problem you see is solved by WebDriverManager - official docs
We are using it in our framework, and it makes all users free from carrying about system properties and versions of a chromedriver. (When you use executable of a chromedriver you will need to be sure to keep it updated with the browser updates as well)
Add the following method to your test class:
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
And don't forget to attach a dependency to WebDriverManager in your pom.xml (Java 8 or upper required):
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
... or in Gradle project:
dependencies {
testCompile("io.github.bonigarcia:webdrivermanager:3.0.0")
}
Important sidenote: remove 'static' from your WebDriver field declaration in a Browser class. Keeping static will not allow you do proceed with parallel tests execution.
edited 2 days ago
answered 2 days ago
Vladimir Efimov
45429
45429
Thanks @Vladimir Efimov. This resulted in errors with slf4j initially. I'm still trying to work through them. I'm also behind a corporate proxy so am likley going to have to do some further customizations. Thanks for pointing this out though, it will likely be very helpful.
– trebleCode
2 days ago
Unfortunately for me, my company is blocking me getting to chromedriver.storage.googleapis.com which that repository tries to reach out to to forcibly download, so that option is dead in the water for me :( However I'm not blocked from the mirror listed for chrome, so that may work! npm.taobao.org/mirrors/chromedriver
– trebleCode
2 days ago
1
If you've arrived here from the future with Google, adding the above dependencies did fix, however there were some additional steps. Create a file called 'log4j.properties' somewhere in your project, and point the configuration class path to the log4j config file. See: stackoverflow.com/questions/7421612/… and stackoverflow.com/questions/12532339/…
– trebleCode
2 days ago
1
Of note, my call in the@BeforeClass setupClass()
looked like:WebDriverManager.chromedriver().proxy("mycompanyproxy.site.com:1234").useMirror().setup();
TheuseMirror()
option works but it cycles through all the versions it finds and chooses an option, which causes some delays but hey it works!
– trebleCode
2 days ago
add a comment |
Thanks @Vladimir Efimov. This resulted in errors with slf4j initially. I'm still trying to work through them. I'm also behind a corporate proxy so am likley going to have to do some further customizations. Thanks for pointing this out though, it will likely be very helpful.
– trebleCode
2 days ago
Unfortunately for me, my company is blocking me getting to chromedriver.storage.googleapis.com which that repository tries to reach out to to forcibly download, so that option is dead in the water for me :( However I'm not blocked from the mirror listed for chrome, so that may work! npm.taobao.org/mirrors/chromedriver
– trebleCode
2 days ago
1
If you've arrived here from the future with Google, adding the above dependencies did fix, however there were some additional steps. Create a file called 'log4j.properties' somewhere in your project, and point the configuration class path to the log4j config file. See: stackoverflow.com/questions/7421612/… and stackoverflow.com/questions/12532339/…
– trebleCode
2 days ago
1
Of note, my call in the@BeforeClass setupClass()
looked like:WebDriverManager.chromedriver().proxy("mycompanyproxy.site.com:1234").useMirror().setup();
TheuseMirror()
option works but it cycles through all the versions it finds and chooses an option, which causes some delays but hey it works!
– trebleCode
2 days ago
Thanks @Vladimir Efimov. This resulted in errors with slf4j initially. I'm still trying to work through them. I'm also behind a corporate proxy so am likley going to have to do some further customizations. Thanks for pointing this out though, it will likely be very helpful.
– trebleCode
2 days ago
Thanks @Vladimir Efimov. This resulted in errors with slf4j initially. I'm still trying to work through them. I'm also behind a corporate proxy so am likley going to have to do some further customizations. Thanks for pointing this out though, it will likely be very helpful.
– trebleCode
2 days ago
Unfortunately for me, my company is blocking me getting to chromedriver.storage.googleapis.com which that repository tries to reach out to to forcibly download, so that option is dead in the water for me :( However I'm not blocked from the mirror listed for chrome, so that may work! npm.taobao.org/mirrors/chromedriver
– trebleCode
2 days ago
Unfortunately for me, my company is blocking me getting to chromedriver.storage.googleapis.com which that repository tries to reach out to to forcibly download, so that option is dead in the water for me :( However I'm not blocked from the mirror listed for chrome, so that may work! npm.taobao.org/mirrors/chromedriver
– trebleCode
2 days ago
1
1
If you've arrived here from the future with Google, adding the above dependencies did fix, however there were some additional steps. Create a file called 'log4j.properties' somewhere in your project, and point the configuration class path to the log4j config file. See: stackoverflow.com/questions/7421612/… and stackoverflow.com/questions/12532339/…
– trebleCode
2 days ago
If you've arrived here from the future with Google, adding the above dependencies did fix, however there were some additional steps. Create a file called 'log4j.properties' somewhere in your project, and point the configuration class path to the log4j config file. See: stackoverflow.com/questions/7421612/… and stackoverflow.com/questions/12532339/…
– trebleCode
2 days ago
1
1
Of note, my call in the
@BeforeClass setupClass()
looked like: WebDriverManager.chromedriver().proxy("mycompanyproxy.site.com:1234").useMirror().setup();
The useMirror()
option works but it cycles through all the versions it finds and chooses an option, which causes some delays but hey it works!– trebleCode
2 days ago
Of note, my call in the
@BeforeClass setupClass()
looked like: WebDriverManager.chromedriver().proxy("mycompanyproxy.site.com:1234").useMirror().setup();
The useMirror()
option works but it cycles through all the versions it finds and chooses an option, which causes some delays but hey it works!– trebleCode
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418110%2fselenium-running-chromedriver-without-modifying-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown