java htmlunitdriver,无法在Selenium中找到元素(htmlUnitDriver)

我无法在selenium中找到一个元素,我使用 htmlUnitDriver . 好的驱动程序工作正常,但我无法找到谷歌搜索文本框元素 .

Here is the code:

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class SampleUnitDriver

{

public static void main(String[] args) throws Exception

{

HtmlUnitDriver unitDriver = new HtmlUnitDriver();

unitDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

unitDriver.get("http://google.com");

System.out.println("Title of the page is -> " + unitDriver.getTitle());

WebElement searchBox = unitDriver.findElement(By.xpath(".//*[@id='gs_htif0']"));

searchBox.sendKeys("Selenium");

WebElement button = unitDriver.findElement(By.name("gbqfba"));

button.click();

System.out.println("Title of the page is -> " + unitDriver.getTitle());

}

}

Here is an Error:

线程“main”中的异常org.openqa.selenium.NoSuchElementException:无法使用.//* [@ id ='gt_htif0'找到节点有关此错误的文档,请访问:http://seleniumhq.org/ exceptions / no_such_element.html构建信息:版本:'2.53.0',修订版:'35ae25b1534ae328c771e0856c93e187490ca824',时间:'2016-03-15 10:43:46'系统信息:主机:'user-PC',ip:' 192.168.1.52',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8.0_51'驱动程序信息:driver.version:组织中的SampleUnitDriver . openga.selenium.htmlunit.HtmlUnitDriver.findElementByXPath(HtmlUnitDriver.java:1165)org.openqa.selenium.By $ ByXPath.findElement(By.java:361)org.openqa.selenium.htmlunit.HtmlUnitDriver $ 5.call(HtmlUnitDriver .java:1725)org.openqa.selenium.htmlunit.HtmlUnitDriver $ 5.call(HtmlUnitDriver.java:1721)org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1367)org.openqa.selenium .htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1 721)在com.digitalmqc.automation.action.SampleUnitDriver.main上的org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:606)(SampleUnitDriver.java:19)

任何帮助都可以得到赞赏 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值