Selenium Chrome和htmlUnit的脚本

时间:2016-11-01 18:06:29

标签: selenium browser-automation

我有一些用于Chrome浏览器的Java脚本,现在我想在htmlUnit中运行脚本。我认为两者的脚本都是一样的,但是在htmlUnit中运行时出现了一些错误?为什么?那么基本上哪些动作(click()?isDisplayed()?等)仅在浏览器测试中而不是在无头测试中?关于这种差异的一般文件?感谢

#########似乎css可能有问题但在Chrome中正常工作

线程“main”中的异常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     在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)

Line461 = driver.findElement(By.cssSelector(“span.icon-meter.enlargeIcon”))。isDisplayed()

1 个答案:

答案 0 :(得分:0)

您在HtmlUnitDriver中启用了javascript吗?
如果是,请在单击之前检查ExpectedConditions

  1. presenceOfElementLocated(如果不确定DOM中是否存在元素)

  2. elementToBeClickable

祝你好运...

相关问题