51Testing软件测试论坛

标题: selenium RC回放脚本遇到的输入问题 [打印本页]

作者: sufen2315    时间: 2010-6-13 10:26
标题: 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");
     }   
}
作者: 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




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2