自动化测试步骤
1)取预期结果;
2)取实际结果;
3)断言:比较1)和2)来判断测试是否通过;
1 package simplewebtest.test;
2
3 import java.util.concurrent.TimeUnit;
4
5 import org.openqa.selenium.By;
6 import org.openqa.selenium.WebDriver;
7 import org.openqa.selenium.firefox.FirefoxDriver;
8 import org.testng.annotations.Test;
9
10 public class TestBaiduHome {
11
12 @Test
13 public void searchSomething(){
14
15 WebDriver driver=new FirefoxDriver();//打开Firefox; open firefox
16 driver.get("http://www.baidu.com");//打开百度open the url
17 driver.findElement(By.id("kw1")).sendKeys("GitHub");//输入搜索关键字“GitHub";input search keyword
18 driver.findElement(By.id("su1")).click();//点击搜索按钮click the search button
19