Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法将PhantomJS驱动程序与Selenium中的Firefox配置文件一起使用_Java_Selenium_Firefox_Webdriver_Phantomjs - Fatal编程技术网

Java 无法将PhantomJS驱动程序与Selenium中的Firefox配置文件一起使用

Java 无法将PhantomJS驱动程序与Selenium中的Firefox配置文件一起使用,java,selenium,firefox,webdriver,phantomjs,Java,Selenium,Firefox,Webdriver,Phantomjs,我尝试在Selenium测试中使用PhantomJS驱动程序,但我没有成功恢复Firefox配置文件以避免登录网站。 这是我的代码: import static org.junit.Assert.fail; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.WebDriv

我尝试在Selenium测试中使用PhantomJS驱动程序,但我没有成功恢复Firefox配置文件以避免登录网站。 这是我的代码:

import static org.junit.Assert.fail;

import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Stackoverflow {
    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();

    @Before
    public void setUp() throws Exception {
        System.setProperty("phantomjs.binary.path", System.getProperty("user.dir") + "/lib/phantomjs-2.1.1-windows/bin/phantomjs.exe");
        DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
        driver = new PhantomJSDriver(capabilities);
        driver.manage().window().maximize();
        baseUrl = "http://stackoverflow.com/";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void testStackoverflow() throws Exception {
        driver.get(baseUrl);
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
        String verificationErrorString = verificationErrors.toString();
        if (!"".equals(verificationErrorString)) {
            fail(verificationErrorString);
        }
    }
}

您能告诉我如何设置PhantomJS驱动程序吗?

您无法将firefox配置文件与PhantomJS一起使用,因为您正在尝试将firefox配置文件与PhantomJS一起使用。。。PhantomJS不是firefox,您认为这将如何工作。

您无法将firefox配置文件与PhantomJS一起使用,因为您试图将firefox配置文件与PhantomJS一起使用。。。PhantomJS不是firefox,您认为它将如何工作。

使用此代码设置PhantomJS驱动程序的路径,使用此代码,如果您遇到任何问题,请告诉我:

File file = new File("E:\\software and tools\\phantomjs-2.1.1-windows\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");               
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());        


使用此代码设置phantomjs驱动程序的路径,使用此代码并让我知道您是否面临任何问题:

File file = new File("E:\\software and tools\\phantomjs-2.1.1-windows\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");               
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());        


我知道这当然不可能,但我问是否有使用firefox配置文件或其他的解决方案。我知道这当然不可能,但我问是否有使用firefox配置文件或其他的解决方案。