How to use Phantomjs for opening a website in Selenium -
i'm trying use headless webkit of phantomjs opening google.com through selenium webdriver when execute code system throws error. phantomjs.exe placed in e directory. please me resolve issue.
public static void main(string[] args) throws exception { desiredcapabilities caps = new desiredcapabilities(); caps.setjavascriptenabled(true); caps.setcapability(phantomjsdriverservice.phantomjs_executable_path_property, "e:\\phantomjs.exe"); webdriver driver = new phantomjsdriver(); driver.get("http://www.google.com"); }
error: exception in thread "main" java.lang.illegalstateexception: path driver executable must set phantomjs.binary.path capability/system property/path variable; more information, see https://github.com/ariya/phantomjs/wiki. latest version can downloaded http://phantomjs.org/download.html @ com.google.common.base.preconditions.checkstate(preconditions.java:197) @ org.openqa.selenium.phantomjs.phantomjsdriverservice.findphantomjs(phantomjsdriverservice.java:236) @ org.openqa.selenium.phantomjs.phantomjsdriverservice.createdefaultservice(phantomjsdriverservice.java:181) @ org.openqa.selenium.phantomjs.phantomjsdriver.(phantomjsdriver.java:104) @ org.openqa.selenium.phantomjs.phantomjsdriver.(phantomjsdriver.java:94) @ multidrivers.main(multidrivers.java:35)
exception in thread "main" java.lang.illegalstateexception: path driver executable must set phantomjs.binary.path capability/system property/path variable;
the above issue due driver not being initialized desiredcapabilities object:
webdriver driver = new phantomjsdriver();
updating code below should solve issue:
webdriver driver = new phantomjsdriver(caps);
let me know if have queries.
Comments
Post a Comment