|
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");
}
} |
|