selenium.click()不工作:EventTarget.dispatchEvent的参数1未实现接口事件 [英] selenium.click() doesn't work: Argument 1 of EventTarget.dispatchEvent does not implement interface Event

查看:237
本文介绍了selenium.click()不工作:EventTarget.dispatchEvent的参数1未实现接口事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下一个问题:



我尝试使用DefaultSelenium对象运行一个简单的点击,如下所示:

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

@When(^我尝试用用户登录\([^ \] *)\和密码\([^ \] *)\ $)
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(字段:+字段+未找到,result);
seleniumClient.type(field,data);

}

这是我的HTML代码:

 < div class =control-group> 
< div class =controls>
< button id =loginname =loginclass =btn btn-primary>登录< / button>
< / div>
< / div>但是,当我运行这个代码,我有下面的异常:


  com.thoughtworks.selenium.SeleniumException:ERROR:命令执行失败。请在日志窗口中的https://groups.google.com/forum/#!forum/selenium-users搜索用户组的错误详细信息。 
错误消息是:EventTarget.dispatchEvent的参数1未实现接口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)
在LoginSteps.I_try_to_login_with_user_and_password(LoginSteps.java:33)
at✽。当我尝试用用户John Doe和密码secret登录(login.feature:8)

my 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

解决方案

我通过升级到最新版本的Selenium(2.42.2)来修复此问题。



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


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

解决方案

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

这篇关于selenium.click()不工作:EventTarget.dispatchEvent的参数1未实现接口事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆