zoukankan      html  css  js  c++  java
  • selenium2 用testNG对百度首页输入框进行测试 (三)

    如果还没有安装testNG的亲,可以点击http://www.cnblogs.com/milanmi/p/4346580.html查看安装过程。

    这节主要是对百度首页的输入框进行输入测试。

    package info.milan.webdriver;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.testng.annotations.AfterClass;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.BeforeClass;
    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.DataProvider;
    import org.testng.annotations.Test;
    
    public class day6 {
        public WebDriver Driver;
        //case,suit单元用例里面,存在多个case可以成为一个簇
        //每个class执行之前调用
        @BeforeClass
        public void Bclass(){
            ///浏览器初始化
            Driver = new FirefoxDriver();
            Driver.manage().window().maximize();
        }
        //每个用例执行之前调用
        @BeforeMethod
        public void setup(){
            Driver.navigate().to("http://www.baidu.com");
        }
        //每个用例执行完毕之后调用
        @AfterMethod
        public void teardown(){
        }
        //每个class执行之后调用
        @AfterClass
        public void Aclass(){
            ///浏览器关闭
            Driver.close();
            Driver.quit();
        }
        //测试用例数据
        @DataProvider(name="logOutDataPro")
        public Object[][]loginOutData(){
            return new Object[][]{{"1"},{"很长很长的观坚持"},{"特殊字符+!@¥"}};
        }
        //执行测试用例
        @Test(dataProvider="logOutDataPro")
        public void baidu(String info){
            Driver.findElement(By.xpath("//*[@id='kw']")).sendKeys(info);
        }
    }
  • 相关阅读:
    PHP XML Expat 解析器
    处理get请求中特殊字符的处理
    bootstrap模态框隐藏事件
    HTML中tr是什么?
    php 日期正则表达式
    # JavaScript中的对象
    python发送get请求
    PHP格式化MYSQL返回float类型的方法
    每日总结
    每日总结
  • 原文地址:https://www.cnblogs.com/milanmi/p/4635877.html
Copyright © 2011-2022 走看看