3.选择options—format,选择java /Junit4/remote control ,选择工作区中的source标签,即显示java脚本51Testing软件测试网5^,_{8Ke@5o$~h
.F#HY2H,H.lS,u(e0
脚本如下,只需修改一下红色部分,即可在Eclipse里运行"w;\J6U9g,D[0
package text.package;-`J/t8t#IS6X0
z$t0b}A;gc%K0
import com.thoughtworks.selenium.*;51Testing软件测试网5R)A QA"p/yq}
import org.junit.After;DxV1GV| g:C(I0
import org.junit.Before;51Testing软件测试网s#Rz1Z2M"W }3WE
import org.junit.Test;51Testing软件测试网G#pC:U9f
import java.util.regex.Pattern;)xZly%{
KF0
W3R!gu?/L6Dv0
public class ClsTestextends SeleneseTestCase{Ql
ap#gs8U2i0
@Before?mIgDP1?0
public void setUp() throws Exception {51Testing软件测试网h2u`0dc_
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.baidu.com/");51Testing软件测试网nl6Ok(gS
selenium.start();P,B^&FTuV0
}+w2O4]FV5d\0
51Testing软件测试网2PSI]4Z;}(V2}
@Test%^g-kw$\x(ko0
public void testTest1() throws Exception {!M+D/h`(r}-o`M0
selenium.open("http://www.baidu.com/");51Testing软件测试网,YG%Za X.`y
selenium.type("id=kw", "12");51Testing软件测试网rQ-C'B3n(y
selenium.click("id=su");#W;U|7a;uXhV0
selenium.waitForPageToLoad("30000");,Nl w
|t0
}51Testing软件测试网3j(e]|/[s{:[?
T!I[QXN0
@AfterZ6V/M#o q0
public void tearDown() throws Exception {J$?3[EqwQm0
selenium.stop();51Testing软件测试网!VpR1u$F
h0pv
}_Oj z%@~*e5_9q0
}51Testing软件测试网#bK&O-I9i5L
4.eclipse新建工程,新建package名称为text.package;新建class为ClsTest,工程属性-Java build path-Add liarbry,添加Junit4。Pu;p4X2Q3d3k-y6PB0
Add external JARS,把selenium-server-standalone-2.25.0.jar、51Testing软件测试网(k4yJ0v_*Zmb
selenium-java-2.25.0.jar添加进来51Testing软件测试网o'e:y*E{(^l
将之前的脚本复制到ClsTest.Java中]T$Cv0{*Bj_.g0
5.启动rc51Testing软件测试网`_%?M6G?R
Cmd进入到selenium-server-standalone-2.25.0.jar所在目录51Testing软件测试网8X}%v?t#y]
输入Java–jar selenium-server-standalone-2.25.0.jar,启动后cmd窗口不能关闭,否则就是停止了51Testing软件测试网5mB%N@ I CKxVD
可以写个批处理来运行rc server(可以使用Java–jar selenium-server-standalone-2.25.0.jar–interactive来交互式启动rc server)