GWT 2.0硒测试 [英] Selenium Testing of GWT 2.0

查看:198
本文介绍了GWT 2.0硒测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能使硒点击()工作作为手动鼠标点击一样的吗?

How can I make a selenium click() work the same as a manual mouse click?

我最近升级GWT从1.7.1到2.0。有些Selenium测试(SeleniumRC V1.0.1,IE7)现在失败。看来,Selenium.click()方法是不选择GWT TreeItem。手动点击将使TreeItem去蓝(即看起来选择,并有在DOMGWT-TreeItem选择class属性),但Selenium测试没有。

I have recently upgraded GWT from 1.7.1 to 2.0. Some selenium tests (SeleniumRC v1.0.1, IE7) are now failing. It seems that the Selenium.click() method is not selecting a GWT TreeItem. A manual click will make the TreeItem go blue (ie. look selected and have "gwt-TreeItem-selected" class attribute in the DOM), but the selenium test doesn't.

我相信,硒实际上是寻找合适的元素,只是没有点击它。如果你改变了字符串参数的点击方法可以检查硒抛出当元素没有发现异常。

I'm convinced that selenium is actually finding the right element, just not clicking on it. If you change the string parameter in the click method you can check that selenium throws an exception when the element isn't found.

下面的示例code使用GWT展示网站。它试图点击单词贝多芬。如果你点击你的鼠标这个词,你会看到TreeItem去蓝色。然而,当你运行Selenium测试,它不会。

The sample code below uses the GWT Showcase website. It tries to click on the word "Beethoven". If you click on that word with your mouse, you'll see the TreeItem go blue. However when you run the selenium test, it won't.

package test;

import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class TestTreeClick {
    static Selenium selenium = null;

    @Before
    public void setUp() throws Exception {
        if (selenium == null) {
            selenium = new DefaultSelenium("localhost", 4444, "*iexplore",
                    "http://gwt.google.com/samples/Showcase/Showcase.html#CwTree");
            selenium.start();
        }
    }

    @Test
    public void testingClicking() {
        selenium.open("http://gwt.google.com/samples/Showcase/Showcase.html#CwTree");
        selenium.click("gwt-debug-cwTree-staticTree-root-child0-content");
    }
}

我曾尝试一些其他的方法(Selenium.clickAt(),Selenium.fireEvent(),Selenium.mouseOver()/向下()/向上()) - 但没有重现手动行为

I have tried some other methods (Selenium.clickAt(), Selenium.fireEvent(), Selenium.mouseOver()/Down()/Up() ) - but none reproduce the manual behaviour.

推荐答案

不幸的是有一个看这个情况下,我一直没能复制与硒点击。我见过很多人抱怨说,他们无法使用Selenium使用GWT,比较有名的球队之一有问题。在谷歌Wave的开发团队已经开始使用的webdriver,以测试他们code。

Unfortunately having a look at this case I have not been able to replicate clicking with Selenium. I have seen a number of people complaining that they can't use Selenium with GWT and one of the more famous teams have that issue. The Google Wave development team have started using WebDriver to test their code.

现在好的事情是,有目前一期工程合并硒的webdriver,因为他们有自己的优点和缺点,其中一些是在不同的区域,以便最终产品将是惊人的。

Now the good thing is that there currently a project to merge Selenium and WebDriver as they have their strengths and weaknesses and a number of them are in different areas so the final product will be amazing.

我相信他们可以在谷歌$有WebDriverBackedSelenium的工作版本C $ç因此,所有你需要做的就是更新硒的实例,它应该开始使用的webdriver code来运行测试。

I believe that they may have a working version of the WebDriverBackedSelenium at Google Code so all you would need to do is update the instantiation of Selenium and it should start using the WebDriver code to run your test.

这篇关于GWT 2.0硒测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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