selenium RC例子

1、先启动selenium server,命令:java -jar selenium-server-standalone-2.44.0.jar

注:也可以把命令做成一个批处理文件,和selenium server放在同一级目录下,方便启动。

2、eclipse里面用junit框架验证selenium脚本的运行结果,如下面的例子:

package autotest;


import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;




@SuppressWarnings("deprecation")
public class test12 {
    
    private Selenium selenium;

    
    @Before
        
    public void setUp() throws Exception {
            
    selenium = new DefaultSelenium("localhost", 4444, "*firefox  C:/program Files (x86)/Mozilla Firefox/firefox.exe", "http://win.emoney.cn/");
            
    selenium.start();
        
        
    }

        
    @Test
        
    public void test121() throws Exception {
            
    selenium.open("/");
            
    selenium.click("id=ds");
            
    selenium.waitForPageToLoad("30000");
            
    assertEquals("中国操盘手滚雪球炒股大赛正式开赛", selenium.getTitle());
        }

        
    @After
        
    public void tearDown() throws Exception {

            
    selenium.stop();
        
    }
}

 这个java脚本是怎么获得的呢?是在selenium IDE中把selenium语言的脚本用Java/Junit/Remote Control格式导出,如下图:

 

转载于:https://www.cnblogs.com/bobo1104/p/4157733.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值