2018-11-19参数化(UI自动化加强)

参数化




parameter

  • 数据与脚本分离,执行xml文件.项目变更脚本不需要动,只修改数据即可
  • 通过@paratroopers注解传参

数据



  
    
    
    

        
        
            
                
                    
                
            
        
    

  

脚本

package com.guoyasoft.autoUI.guoya_1810;

import com.guoyasoft.autoUI.common.BaseUI;
import org.openqa.selenium.By;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class parameter extends BaseUI {
  @Test
  @Parameters({"url","username","password","realname"})
  public void parameter(String url,String username,String password,String realname){
    //"http://47.98.226.232:8080/guoya-medium/jsp/user/login.jsp"
    driver.get(url);
    driver.findElement(By.xpath("//input[@name='userName']")).sendKeys(username);
    driver.findElement(By.xpath("//input[@name='password']")).sendKeys(password);
    driver.findElement(By.xpath("//input[@id='checkCode']")).sendKeys("1234");
    driver.findElement(By.xpath("//input[@id='loginBtn']")).click();
    driver.findElement(By.name("realName")).clear();
    driver.findElement(By.name("realName")).sendKeys(realname);
    driver.findElement(By.xpath("//input[@value='查询']")).click();
  }

}

你可能感兴趣的:(2018-11-19参数化(UI自动化加强))