【发布时间】:2017-03-14 22:33:39
【问题描述】:
我有一些用于 Chrome 浏览器的 Java 脚本,现在我想在 htmlUnit 中运行这些脚本。我认为两者的脚本是相同的,但是在 htmlUnit 中运行时出现了一些错误?为什么?那么基本上哪些动作(click()?isDisplayed()?等)仅在浏览器测试中而不是在无头测试中?和关于这种差异的一般文件?谢谢
线程“主”org.openqa.selenium.NoSuchElementException 中的异常:
返回的节点不是 HTML 元素有关此错误的文档,
请访问:http://seleniumhq.org/exceptions/no_such_element.html
构建信息:版本:'2.45.0',修订:'32a636c',时间:'2015-03-05
22:01:35' 系统信息:主机:'FGS-CIT-2758',ip:'192.168.200.201',
os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.8.0_40' 驱动程序信息:driver.version:HtmlUnitDriver at
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByCssSelector(HtmlUnitDriver.java:1002)
在 org.openqa.selenium.By$ByCssSelector.findElement(By.java:426) 在
org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1648)
在
org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1)
在
org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1302)
在
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1644)
在
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:550)
在 com.ATIP400Suite.CH_ATIP40.mainCheck(CH_ATIP40.java:461) 在
com.ATIP400Suite.CH_ATIP40.main(CH_ATIP40.java:58)第 461 行 =
driver.findElement(By.cssSelector("span.icon-meter.enlargeIcon")).isDisplayed()
【问题讨论】:
-
Select() 似乎也有问题 - - Select period = new Select(driver.findElement(By.xpath("//select"))); period.getFirstSelectedOption().getText()
-
欢迎来到 Stackoverflow。请阅读How to create a Minimal, Complete, and Verifiable example,然后考虑修改您的问题,以便人们有足够的信息来提供帮助。
标签: selenium browser-automation