实战目标
- 企业微信的用户管理
课堂ppt
PPT地址
框架
Selenium
- Web自动化框架
控制浏览器
在浏览器上进行操作,输入、获取页面内容、点击、js
JUnit5
- 测试框架 ,管理测试用例
@Before. @Test @Tag
@Suite
管理测试用例集
环境的区分
测试用例执行顺序。@Suite @Order
数据的隔离、数据驱动
qa : test1.yaml
master: dev
Allure
- 报告
知识汇总
汇总.zip (1.9 MB)
chromedriver
$ chromedriver
Starting ChromeDriver 98.0.4758.80 (7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758@{#972}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
下载地址
webdrivermanager
使用方法
//判断是否有浏览器
Optional<Path> browserPath = WebDriverManager.chromedriver().getBrowserPath();
assumeThat(browserPath).isPresent();
//使用WebDriverManager创建driver打开浏览器 .cache/selenium
WebDriver webDriver = WebDriverManager.chromedriver().create();
pom文件
<properties>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<maven.compiler.version>3.10.1</maven.compiler.version>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<!-- 使用 Java 11 语言特性 ( -source 11 ) 并且还希望编译后的类与 JVM 11 ( -target 11 )兼容,
可以添加以下两个属性,它们是默认属性插件参数的名称 -->
<java.version>11</java.version>
<!-- 对应junit Jupiter的版本号;放在这里就不需要在每个依赖里面写版本号,导致对应版本号会冲突 -->
<junit.jupiter.version>5.9.1</junit.jupiter.version>
<!-- log日志 -->
<slf4j.version>2.0.3</slf4j.version>
<logback.version>1.4.3</logback.version>
<!-- allure报告 -->
<allure.version>2.19.0</allure.version>
<aspectj.version>1.9.9.1</aspectj.version>
<allure.maven.version>2.11.2</allure.maven.version>
<!-- 旧版本 <allure.maven.version>2.10.0</allure.maven.version> -->
<allure.cmd.download.url>
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline
</allure.cmd.download.url>
<!-- hamcrest断言 -->
<hamcrest.version>2.2</hamcrest.version>
<!-- yaml对应解析 -->
<jackson.version>2.13.4</jackson.version>
<!-- selenium安装 -->
<selenium.verison>4.5.3</selenium.verison>
<webdriver.manager.version>5.3.0</webdriver.manager.version>
<assertj.version>3.23.1</assertj.version>
</properties>
<!-- 物料清单 (BOM)-->
<dependencyManagement>
<dependencies>
<!--当使用 Gradle 或 Maven 引用多个 JUnit 工件时,此物料清单 POM 可用于简化依赖项管理。不再需要在添加依赖时设置版本-->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- junit5 -->
<!-- 创建 Junit5 测试用例的 API-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<!--对应添加的依赖的作用范围-->
<scope>test</scope>
</dependency>
<!-- 兼容 JUnit4 版本的测试用例-->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<!--suite套件依赖 -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<!-- log日志 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>compile</scope>
</dependency>
<!-- allure报告-->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit5</artifactId>
<version>${allure.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<!-- yaml文件解析-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<!-- hamcrest断言 -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<!-- selenium安装 -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.verison}</version>
</dependency>
<!-- webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>${webdriver.manager.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<!-- 设置jre版本为 11 -->
<source>${java.version}</source>
<target>${java.version}</target>
<!-- 设置编码为 UTF-8 -->
<encoding>${maven.compiler.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- <argLine>-->
<!-- -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"-->
<!-- </argLine>-->
<includes>
<include>**/SubTest</include>
<!-- <include>**/*Test</include>-->
<!-- <include>**/Test*</include>-->
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure.maven.version}</version>
<configuration>
<reportVersion>${allure.version}</reportVersion>
<allureDownloadUrl>${allure.cmd.download.url}/${allure.version}/allure-commandline-${allure.version}.zip</allureDownloadUrl>
</configuration>
</plugin>
</plugins>
</build>