selenium RC回放脚本遇到的输入问题
selenium RC回放脚本,百度页面可以打开,但是无法输入。停在 selenium.type("kw", "selenium");
代码如下:
import junit.framework.TestCase;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
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");
}
} problem with baiduhome 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.
回复 2# 的帖子
thanks
页:
[1]