Maven PhantomJSDriver的WebDriverManager不工作

Maven PhantomJSDriver的WebDriverManager不工作,maven,selenium,selenium-webdriver,phantomjs,Maven,Selenium,Selenium Webdriver,Phantomjs,我不能上班。我希望使用PhantomJSDriver,而不必像这样设置系统属性: System.setProperty("phantomjs.binary.path", "E:/phantomjs-2.1.1-windows/bin/phantomjs.exe"); 我的pom.xml中有以下依赖项: <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId&

我不能上班。我希望使用PhantomJSDriver,而不必像这样设置系统属性:

System.setProperty("phantomjs.binary.path", "E:/phantomjs-2.1.1-windows/bin/phantomjs.exe");
我的pom.xml中有以下依赖项:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>3.0.1</version>
    </dependency>
<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>1.5.1</version>
</dependency>
测试失败:

org.junit.ComparisonFailure: expected:<[Google]> but was:<[]>

现在,当我用
System.setProperty(…)
删除该行时,它不再工作了。感谢您的帮助。

看起来像是您将断言设置为early,因此当您调用getTitle()时,页面不会被加载。你的打印输出是什么

尝试在测试中添加一个wait to,如果你知道页面标题应该是“Google”,那么为什么不在做任何进一步的断言之前等待它成为真的呢?当页面标题与您的期望值相等时,您可以合理地确信页面已加载。试试这个:

public Boolean waitForPageIsLoaded(String title) {
    return new WebDriverWait(driver, 10).until(ExpectedConditions.titleIs(title));
}

看起来您将断言设置为early,因此在调用getTitle()时不会加载页面。你的打印输出是什么

尝试在测试中添加一个wait to,如果你知道页面标题应该是“Google”,那么为什么不在做任何进一步的断言之前等待它成为真的呢?当页面标题与您的期望值相等时,您可以合理地确信页面已加载。试试这个:

public Boolean waitForPageIsLoaded(String title) {
    return new WebDriverWait(driver, 10).until(ExpectedConditions.titleIs(title));
}

检查它是否确实下载了PhantomJS二进制文件。从它的代码中,我看到它生成日志。将它们附加到问题或使用它们来解决此问题。检查它是否确实下载了PhantomJS二进制文件。从它的代码中,我看到它生成日志。把它们附在问题上,或者用它们来解决这个问题。出于某种原因,我认为同样的测试也适用于FirefoxDriver,但事实并非如此。你的答案对我有用,谢谢!我现在有另一个问题,我更新了我的问题。问一个新问题我下周会问这个新问题。我现在工作上还有其他事情要做。不过,到目前为止,这还是有帮助的!出于某种原因,我原以为FirefoxDriver也可以进行同样的测试,但事实并非如此。你的答案对我有用,谢谢!我现在有另一个问题,我更新了我的问题。问一个新问题我下周会问这个新问题。我现在工作上还有其他事情要做。不过,到目前为止,这还是有帮助的!谢谢
public Boolean waitForPageIsLoaded(String title) {
    return new WebDriverWait(driver, 10).until(ExpectedConditions.titleIs(title));
}