2013-10-03 20 views
4

我有一个问题:selenium.click()不工作:EventTarget.dispatchEvent的参数1未实现接口事件

我试图运行一个简单的点击与DefaultSelenium对象就像这样:

private DefaultSelenium seleniumClient = new DefaultSelenium("localhost", 4444, "*firefox", 
     "http://localhost:8080"); 

    @When("^I try to login with user \"([^\"]*)\" and password \"([^\"]*)\"$") 
    public void I_try_to_login_with_user_and_password(String userName, String password) throws Throwable { 
    enterData("id=username", userName); 
    enterData("id=password",password); 
    seleniumClient.click("id=login"); 
} 

private void enterData(String field, String data) throws Exception { 
    boolean result = seleniumClient.isElementPresent(field); 
    Assert.assertTrue("the field: "+ field +" was not found",result); 
    seleniumClient.type(field, data); 

} 

,这是我的HTML代码:

<div class="control-group"> 
       <div class="controls"> 
        <button id="login" name="login" class="btn btn-primary">Login</button> 
       </div> 
    </div> 

但是,当我运行此代码,我有一个异常:

com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure. Please search the user group at https://groups.google.com/forum/#!forum/selenium-users for error details from the log window. 
The error message is: Argument 1 of EventTarget.dispatchEvent does not implement interface Event. 
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112) 
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106) 
at com.thoughtworks.selenium.DefaultSelenium.click(DefaultSelenium.java:193) 
at LoginSteps.I_try_to_login_with_user_and_password(LoginSteps.java:33) 
at ✽.When I try to login with user "John Doe" and password "secret"(login.feature:8) 

我pom.xml文件有:

<dependency> 
     <groupId>info.cukes</groupId> 
     <artifactId>cucumber-picocontainer</artifactId> 
     <version>1.1.5</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-java</artifactId> 
     <version>2.35.0</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-server</artifactId> 
     <version>2.35.0</version> 
     <scope>test</scope> 
    </dependency> 

的任何想法: “论证EventTarget.dispatchEvent 1没有实现接口的事件。”

我只在谷歌组发现这一点:https://groups.google.com/forum/#!topic/selenium-users/ZLbzGeafQu4

+0

我在使用特定版本的Firefox和Selenium之前,我们看到了这个错误。本周Firefox没有推出新版本吗?如果你正在运行FF,你可以尝试降级。 – rutter

+0

其实我仍然有问题...并且我使用firefox 25和selenium 2.35.0 – Icaro

+1

根据他们的[changelog](https://code.google.com/p/selenium/source/browse/java/CHANGELOG) ,Selenium 2.35支持Firefox 23. – rutter

回答