selenium2 对之前的rc 代码提供了兼容性接口,如果你之前的code 都是用rc 写,而现在又想摆脱要每次启动server,你只需要 略做修改即可。代码如下:
public class TestWb extends SeleneseTestCase { @Before public void setUp() throws Exception { WebDriver driver = new FirefoxDriver(); String baseUrl = "http://www.baidu.com/"; selenium = new WebDriverBackedSelenium(driver, baseUrl); } @Test public void testWb() throws Exception { selenium.open(baseUrl); selenium.type("id=kw", "hello"); selenium.click("id=su"); selenium.waitForPageToLoad("30000"); } @After public void tearDown() throws Exception { selenium.stop(); }
更多资料关注:www.kootest.com ;技术交流群:182526995
时间: 2024-10-11 06:44:16