20221106 web自动化测试实战二

实战目标

  • PO设计模式

课堂ppt

PPT地址

报错

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableMap;

解决方式一:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>31.0.1-jre</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

解决方式2:

<dependency>  
    <groupId>io.github.bonigarcia</groupId>  
    <artifactId>webdrivermanager</artifactId>  
    <version>5.0.3</version>  
    <exclusions>  
        <exclusion>  
            <groupId>com.google.guava</groupId>  
            <artifactId>guava</artifactId>  
        </exclusion>  
    </exclusions>  
</dependency>

随机数

<dependencies>
        <dependency>
            <groupId>com.github.javafaker</groupId>
            <artifactId>javafaker</artifactId>
            <version>1.0.2</version>
        </dependency>

    </dependencies>

import com.github.javafaker.Faker;

import java.util.Locale;

public class FakerUtil {
    static Faker faker = new Faker(Locale.SIMPLIFIED_CHINESE);
    private static String[] telFirst="134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(",");
    //名字
    public static String get_name(){
        String name = faker.name().fullName();
        return name;
    }
    public static String get_zh_phone(){
        //随机生成8位的电话号
        String s = faker.phoneNumber().subscriberNumber(8);
        //随机生成手机号开端的下标
        int index= getNum(0,telFirst.length-1);
        //获取手机号开头三位数
        String first=telFirst[index];
        //返回手机号
        return first + s;
    }
    //11位  897 567
    public static String get_phone(){
        return faker.phoneNumber().phoneNumber();
    }
    public static String get_acctid(){
        return faker.phoneNumber().subscriberNumber(12);
    }
    public static int getNum(int start,int end) {
        return (int)(Math.random()*(end-start+1)+start);
    }


}

ChromeOptions option = new ChromeOptions();
//不显示 Chrome正受到自动测试软件的控制 提示栏
option.setExperimentalOption("excludeSwitches", new String[] {"enable-automation","load-extension"});
// 最大化窗口
option.addArguments("--start-maximized");

作业

  • 删除成员用例
  • 添加成员、删除成员参数化
  • suite套件顺序运行添加成员、删除成员
  • 生成allure报告,添加步骤截图、解释说明、用例说明

https://gitee.com/neej/autoApi/tree/master/src/main/java/com/wecat/podesign