我正在使用标准示例: cucumber-jvm-selenium-example
当我运行测试时:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.michalvich.cucumber.selenium.example.GoogleSearchTest
Feature: Search on Google
As an user
I want to search on Google
So that I can see results
Scenario: results are shown # com\michalvich\cucumber\selenium\example\GoogleSearch.feature:6
Given the page is open "http://www.google.com" # GoogleSearchScenario.the_page_is_open(String)
[1A Given the page is open "http://www.google.com" # GoogleSearchScenario.the_page_is_open(String)
When I search for "Cucumber" # GoogleSearchScenario.I_search_for(String)
[1A When I search for "Cucumber" # GoogleSearchScenario.I_search_for(String)
org.openqa.selenium.NoSuchElementException: Unable to locate element with name: q
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 15:53:30'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
Driver info: driver.version: HtmlUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByName(HtmlUnitDriver.java:749)
at org.openqa.selenium.By$ByName.findElement(By.java:292)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1247)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1244)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:987)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1244)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:393)
at com.michalvich.cucumber.selenium.example.GoogleSearchScenario.I_search_for(GoogleSearchScenario.java:26)
at ?.When I search for "Cucumber"(com\michalvich\cucumber\selenium\example\GoogleSearch.feature:8)
但是,如果我更改驱动程序:
System.setProperty("webdriver.chrome.driver", "path\\to\\chromedriver.exe");
driver = new ChromeDriver();
有用。