• 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);
        }
    }
  • 相关阅读:
    支付包接口支付缓存问题
    vue多层弹框时存在遮挡应如何解决
    P1520 因式分解 题解
    观测概率为多维高斯分布时对两(多)类MAP决策边界的分析
    关于因数个数的估计
    使用ITTP_Stream显示图像
    linux某个目录没有可执行权限
    linux ldd命令
    注意力机制
    transformer
  • 原文地址:https://www.cnblogs.com/milanmi/p/4635877.html
Copyright © 2020-2023  润新知