Reputation: 21
Can someone tell me how I begin to test with PhantomJS? I have downloaded the PhantomJS exe file and also set my "path" variable.
And I do something similar for chrome like
if(config.getProperty("browser").equals("chrome"))
{
System.setProperty("webdriver.chrome.driver", "C:drivers\\chromedriver.exe");
driver= new ChromeDriver();
}
which is
if(config.getProperty("browser").equals("phantom"))
{
System.setProperty("webdriver.chrome.driver", "C:\\drivers\\chromedriver.exe");
driver= new PhantomJSDriver();
}
But, this does not work. Please help. I do not want to use RemoteWebDriver or GhostDriver
Upvotes: 0
Views: 5343
Reputation: 43
Find the phantomjs code below and set the property key and value:
//System.setProperty("phantomjs.binary.path","phantomjs.exe path");
System.setProperty("phantomjs.binary.path", System.getProperty("user.dir")+"/ExternalLibraryFiles/phantomjs-2.1.1-windows/phantomjs-2.1.1-windows/bin/phantomjs.exe");
driver =new PhantomJSDriver();
Upvotes: 0
Reputation: 1
PhantomJSDriver accepts path to executable as a constructor argument:
if (config.getProperty("browser").equals("phantom"))
driver= new PhantomJSDriver("C:\\drivers\\chromedriver.exe");
Upvotes: 0
Reputation: 21
I figured it out:
if(config.getProperty("browser").equals("phantom"))
{
System.setProperty("phantomjs.binary.path", "C:\\drivers\\chromedriver.exe");
driver= new PhantomJSDriver();
}
Upvotes: 2