首页 > 学院 > 开发设计 > 正文

selenium使用junit单元测试框架编写webdriver脚本_04

2019-11-06 09:50:25
字体:
来源:转载
供稿:网友

1.新建一个java工程->引入seleniumWebDriver类库->引入JUnit4类库,编辑以下代码并执行:

public class Demo1 {

   WebDriver driver;

   @Before

   public void setUp() throws Exception{

      System.setPRoperty("webdriver.Firefox.bin","D://firefox//firefox.exe");

      driver=newFirefoxDriver();

   }

   @Test

   public void test() {

      driver.get("https://www.sogou.com/");

      driver.findElement(By.id("query")).sendKeys("测试");

      driver.findElement(By.id("stb")).click();

   }

   @After

   public voidtearDown() throws Exception {

      Thread.sleep(5000);

      driver.quit();

   }

}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表