selenium.click() doesn't work: Argument 1 of EventTarget.dispatchEvent does not implement interface Event

旧街凉风 提交于 2019-12-10 16:29:36

问题


I have the next problem:

I try to run a simple click with DefaultSelenium object just like this:

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);

}

and this is my HTML code:

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

But, when I run this code, I have the next exception:

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)

my pom.xml file have:

    <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>

Any Idea for: "Argument 1 of EventTarget.dispatchEvent does not implement interface Event."

I only find this in google groups: https://groups.google.com/forum/#!topic/selenium-users/ZLbzGeafQu4


回答1:


I fixed this exact issue by upgrading to the latest version of Selenium (2.42.2)

For Netbeans, see: https://netbeans.org/bugzilla/show_bug.cgi?id=245162



来源:https://stackoverflow.com/questions/19168227/selenium-click-doesnt-work-argument-1-of-eventtarget-dispatchevent-does-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!