【发布时间】:2012-05-25 07:40:42
【问题描述】:
我现在很困惑,我不明白为什么我的代码不能按我需要的那样工作。事实上,每次有新的测试时,它都会关闭 firefox 并重新打开它。这让我的测试需要很长时间才能意识到......你能告诉我我做错了什么吗?
public class SeleniumTestLoginEntry extends SeleneseTestCase {
private String login="scLocator=//DynamicForm[ID=\"formulaire_login\"]/item[index=0||Class=TextItem]/element";
private String passwd="scLocator=//DynamicForm[ID=\"formulaire_login\"]/item[index=1||Class=PasswordItem]/element";
static public DefaultSelenium selenium;
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4500, "*firefox", "http://localhost:9091/");
selenium.start();
}
public void testFields() throws Exception {
selenium.open("/agepro-prototype/login/Login.html");
selenium.type(login, "Unlogin");
selenium.type(passwd, "Unpassword");
Assert.assertEquals("Unlogin", selenium.getValue(login));
Assert.assertEquals("Unpassword", selenium.getValue(passwd));
selenium.click("scLocator=//ImgButton[ID=\"bouton_login\"]/");
}
public void testSameWindow() throws Exception {
selenium.open("/agepro-prototype/login/Login.html");
selenium.type(login, "truc");
Assert.assertEquals("truc", selenium.getValue(login));
}
public void tearDown() throws Exception {
selenium.stop();
}
}
我尝试将注释@BeforeClass 和@AfterClass 放在setUp() 和tearDown 之前,它不会改变任何东西。在每次测试之前都有一个 @Test 之前,但这根本没有帮助。我可以请你帮忙吗? =)
编辑:哦,我也在 setUp() 中尝试了 selenium.open(blablabla) 而不是直接在测试中,同样的问题,不会改变任何事情。
【问题讨论】:
-
不相关,但有什么理由让您仍在使用 Selenium RC - 已正式弃用。
-
代码中的注释(@Something)在哪里?
-
@Arran 是的,webdriver 与 smartGWT 和 user-extensions.js 不兼容。简单的。弗兰克 我试过了,没用,把它们删掉了。但是我现在找到了解决方案,一切都很好:D
-
如果你的解决方案成功了,为什么不把你的示例代码放在这个线程中呢?它将帮助任何需要面对类似问题的人更好地理解。
标签: java maven selenium selenium-rc