如何将phantomjs链接到硒?

时间:2014-01-20 13:23:29

标签: selenium-webdriver phantomjs

我尝试使用phantomjs运行selenium。但脚本停止运行而没有响应。如何使用phantomjs运行硒?

2 个答案:

答案 0 :(得分:0)

driver = webdriver.PhantomJS(executable_path ='C:\ location \ of \ phantomjs.exe')

答案 1 :(得分:0)

这可能会有所帮助:

PhantomJSDriver driver;
WebDriverWait wait;
DesiredCapabilities capabilities;

Test1()
{

    //set binary path of phantomJS driver
    capabilities = new DesiredCapabilities();
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "drivers/phantomjs.exe");
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_SETTINGS_PREFIX,"Y");
    //intialize driver and set capabilties
    driver = new PhantomJSDriver(capabilities);
    //intitlaize webdriverwait class
    wait = new WebDriverWait(driver, 30);
}