haiquan180 发表于 2012-4-17 14:41:56

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

本帖最后由 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)
页: [1]
查看完整版本: selenium 测试google 无法找到“Google 搜索”这个东东