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.