【问题标题】:selenium.click() doesn't work: Argument 1 of EventTarget.dispatchEvent does not implement interface Eventselenium.click() 不起作用:EventTarget.dispatchEvent 的参数 1 没有实现接口事件
【发布时间】:2013-10-03 20:03:04
【问题描述】:

我有下一个问题:

我尝试使用 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 没有实现接口事件。”

我只在 google 群组中找到这个:https://groups.google.com/forum/#!topic/selenium-users/ZLbzGeafQu4

【问题讨论】:

  • 我以前在使用特定版本的 Firefox 和 Selenium 时看到过该错误。 Firefox 不是在本周推出了新版本吗?如果您正在运行 FF,您可以尝试降级。
  • 其实我还是有问题...我使用的是 firefox 25 和 selenium 2.35.0
  • 根据他们的changelog,Selenium 2.35 最高支持 Firefox 23。
  • 是的......但是..,实际上这是一个错误code.google.com/p/selenium/issues/detail?id=6112

标签: java maven selenium cucumber bdd


【解决方案1】:

我通过升级到最新版本的 Selenium (2.42.2) 解决了这个问题

对于 Netbeans,请参阅:https://netbeans.org/bugzilla/show_bug.cgi?id=245162

【讨论】:

    猜你喜欢
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 2018-05-12
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    • 2022-07-08
    • 1970-01-01
    相关资源
    最近更新 更多