Gle*_*nnn 11 gwt selenium automated-tests
如何使selenium click()与手动鼠标点击一样工作?
我最近将GWT从1.7.1升级到2.0.一些硒测试(SeleniumRC v1.0.1,IE7)现在失败了.似乎Selenium.click()方法没有选择GWT TreeItem.手动单击将使TreeItem变为蓝色(即,看起来已选中并且在DOM中具有"gwt-TreeItem-selected"类属性),但是selenium测试不会.
我确信硒实际上找到了正确的元素,而不是点击它.如果在click方法中更改字符串参数,则可以检查selenium在找不到元素时抛出异常.
下面的示例代码使用GWT Showcase网站.它试图点击"贝多芬"这个词.如果用鼠标单击该单词,您将看到TreeItem变为蓝色.但是,当你进行硒测试时,它不会.
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");
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一些其他方法(Selenium.clickAt(),Selenium.fireEvent(),Selenium.mouseOver()/ Down()/ Up()) - 但没有重现手动行为.
不幸的是看看这个案例,我无法用Selenium复制点击.我看到很多人抱怨他们不能将Selenium与GWT一起使用,其中一个更有名的团队也有这个问题.Google Wave开发团队已开始使用WebDriver测试其代码.
现在的好消息是,有目前一期工程合并硒webdriver的,因为他们有自己的优点和缺点,许多人都在不同的领域,因此最终产品将是惊人的.
我相信他们可能在Google Code上有一个WebDriverBackedSelenium的工作版本,所以你需要做的就是更新Selenium的实例化,它应该开始使用WebDriver代码来运行你的测试.
| 归档时间: |
|
| 查看次数: |
12738 次 |
| 最近记录: |