51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3123|回复: 2
打印 上一主题 下一主题

selenium RC回放脚本遇到的输入问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2010-6-13 10:26:28 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
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");
     }   
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2010-6-18 15:31:18 | 只看该作者

回复 2# 的帖子

thanks
回复 支持 反对

使用道具 举报

该用户从未签到

2#
发表于 2010-6-18 08:07:37 | 只看该作者
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.
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-27 19:19 , Processed in 0.086501 second(s), 31 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表