【发布时间】:2011-02-23 17:34:56
【问题描述】:
当我在 Selenium IDE 中使用 JUnit 4 格式化程序生成的代码时,我收到警告说 SeleneseTestCase 类已被弃用 - 这是有道理的,因为它应该使用 JUnit 4 语法并使用注释而不是从测试类派生。
问题是当我修改我的代码以不扩展 SeleneseTestCase 时,我不确定如何调用 verify* 方法 - 它们似乎只存在于已弃用的类中。我可以使用下面的代码运行我的 selenium 操作,但 verifyTrue 未定义。在 Selenium 2.0b2 中调用验证方法的正确方法是什么?
private static Selenium selenium;
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://testurl.com/");
selenium.start();
}
@Test
public void testLogin() throws Exception {
selenium.open("/test.html");
verifyTrue(selenium.isTextPresent("Please Sign In"));
.....
【问题讨论】:
-
这篇文章展示了 Selenium Java 测试用例的正确 JUnit4 格式,但没有展示如何验证文本 qtp-help.blogspot.com/2009/05/junit-4.html
-
不要声明你的
Seleniumstatic! -
哎呀 - 谢谢 - 玩太多代码了!