51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2240|回复: 0
打印 上一主题 下一主题

selenium 测试google 无法找到“Google 搜索”这个东东

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2012-4-17 14:41:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 haiquan180 于 2012-4-17 14:43 编辑

WebDriver driver = new HtmlUnitDriver();   
                driver.get("http://www.google.com.hk");
                driver.findElement(By.name("q")).sendKeys("Cheese!");
                driver.findElement(By.name("btnK")).click();//这行报错

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element with name: btnK
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.20.0', revision: '16008', time: '2012-02-28 15:00:40'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_03'
Driver info: driver.version: HtmlUnitDriver
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByName(HtmlUnitDriver.java:746)
    at org.openqa.selenium.By$ByName.findElement(By.java:292)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1244)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1241)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:984)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1241)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:396)
    at com.crown.suite.Example.main(Example.java:36)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-5-10 18:02 , Processed in 0.088106 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表