51Testing软件测试网4ZAxN'~XBEN4c
51Testing软件测试网3{g$FH
U{0o
import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import com.thoughtworks.selenium.*;
import
java.util.regex.Pattern;
51Testing软件测试网)x/tV/MN,Q0b&k8c;o
import junit.framework.TestCase;
51Testing软件测试网3qH QmKTe9~l
import org.testng.annotations.*;
51Testing软件测试网xv+v,R7N6uK^
public class NewTest extends TestCase{
@Test()
public void testNew() throws Exception {
Selenium selenium = new DefaultSelenium("localhost",4444,"*chrome","http://www.google.cn");
script(selenium);
}
@Test()
public void testNew2() throws Exception {
Selenium selenium = new DefaultSelenium("localhost",4444,"*iehta","http://www.google.cn");
script(selenium);
}
private void script(Selenium selenium)throws Exception{
try{
selenium.start();
selenium.open("http://www.google.cn/");
selenium.type("q", "selenium");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
assertEquals("selenium -
Google 搜索", selenium.getTitle());
}catch(Exception e){
throw e;
}finally{
selenium.stop();
}
}
}