硒测试失败无头,但通过Chrome浏览器

时间:2017-04-27 00:59:46

标签: java selenium selenium-webdriver automated-tests

我在primefaces / jsf应用程序中打开一个对话框,对话框窗口有一个用于搜索的输入文本和下拉列表...

硒测试在头部模式下用于铬。 但是,在无头模式下运行时,下拉列表无法选择。

请参阅以下代码:

List<String> messages = Arrays.asList("ping", "ping_back");
if (messages.contains("ping")) {
     System.out.println("message is ping");
}
if (!messages.contains("test")) {
    System.out.println("no message for test");
}

错误消息是:

clickElement(DriverFactory.getFactory().getDriver().findElement(By.id(idPrefix + "_label")));
clickElement(DriverFactory.getFactory().getDriver().findElement(By.xpath("//div[@id='" + idPrefix + "_panel']/div/ul/li[text()='" + selection + "']")));

以下是我的驱动程序配置逻辑:

org.openqa.selenium.NoSuchElementException: Unable to locate a node using //div[@id='refDataSelForm:fileVersion_panel']/div/ul/li[text()='Current']
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'ONS21861', ip: '10.194.138.207', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: HtmlUnitDriver
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByXPath(HtmlUnitDriver.java:1161)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1715)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1711)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1363)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1711)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:606)

请知道为什么搜索在头模式下成功选择下拉菜单,但不是在头模式下。

0 个答案:

没有答案