public class GoogleTest extends TestCase {
private Selenium selenium;
public void setUp() throws Exception{
String url="http://www.baidu.com";
selenium=new DefaultSelenium("localhost",4444, "*iexplore", url);
System.out.println("init selenium");
selenium.start();
System.out.println("start successfully");
super.setUp();
}
public void tearDown() throws Exception{
selenium.stop();
super.tearDown();
}
public void testGoogleTestSearch() throws Throwable {
System.out.println("enter testGoogleTestSearch");
selenium.open("http://www.baidu.com");
selenium.windowMaximize();
System.out.println("open the google.com");
selenium.type("kw", "selenium");
System.out.println("input type condition");
selenium.click("su");
System.out.println("begin search");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("s"));
System.out.println("finsh assert");
}
}作者: goal1860 时间: 2010-6-18 08:07
problem with baidu home page, try using waitForCondition or waitForElementPresent instead of waitForPageToLoad. Or practice on google if it is only learning purpose. Baidu is not a good example to get start with.作者: sufen2315 时间: 2010-6-18 15:31 标题: 回复 2# 的帖子 thanks