# UI Automated Testing Framework for Web and App
[简体中文](./README.cn.md) | English
> Selenium 4 has come. I am modifying this project to fix with it. And almost done.
> If you use the old Selenium 3 still, go to the branch `backup-Selenium3`.
---
# Project Brief
+ This is a **UI test automation framework for Web/Android/iOS/H5**, and supports Android performance testing. The core
of the project uses Selenium/Appium.
+ The project uses Maven for project management and TestNG for test case management.
+ The common Selenium APIs are encapsulated, such as `click()`, `type()`, etc. And they are added element availability
verification, log recording, and taking screenshot for failed tests.
+ WebUI, AndroidUI and iOSUI are separate modules. According to OS features, special base class methods have been
written,
and the configuration file `config.properties` under the module root directory will not affect each other.
+ A testcase can test online or offline environment at the same time by different tests data driven.
+ Log and assertion have been encapsulated into LogUtil and AssertUtil, which is easy to replace or extend in the
future.
+ WebDriverManager carries out the management (i.e., download, setup, and maintenance) of the web drivers in a fully
automated manner.
+ Android: If `mapping.txt` the resource obfuscation file is provided, the framework can automatically replace the
original element id with the obfuscated id, and then the positioning elements work fine.
# Environmental preparation
## Requirements
1. JDK >= 8 (The minimum Java version required is still 8.)
2. Maven >= 3
3. Selenium 4
4. Appium (java-client 8)
5. TestNG 6 -- TODO: to replace testNg with Junit
6. IDE (Eclipse or others, this tutorial takes Eclipse as an example) + TestNG plugin + Maven plugin
## Android
1. Install `Android SDK`
1.1 Configure environment variables
1.2 Verify `adb` in the console whether it run ok or not
1.3 If you are about to run the test cases on emulators, you need to create emulators using `AVD Manager`
2. Install the Appium server program, see [http://appium.io/](http://appium.io/). Recommend to install it in the way
of `Appium Desktop`.
## iPhone
1. **macOS is required!**
1.1 Appium Server's operation, element recognition, and script execution all require the macOS
1.2 Install Xcode, verify the installation until the tested app can be compiled successfully and can be run in a
simulator
2. If you want to run test case on a device, follow the
manual [Deploying an iOS app to a real device](http://appium.io/slate/en/master/)
3. Install the Appium server program, after installation, you will find that it has more support for iOS testing than
the Windows version
![Appium Server Mac](/docs/images/appium-server-mac.png)
# Project Structure
```
├─perftest_android <-- Android performance test module
│ ├─perfreport <-- Performance test result
│ └─src <-- test case
├─uitest_android <-- Android ui test module
│ ├─app <-- Store tested `apk` and `mapping` files
│ ├─testdata <-- test data,csv format
│ │ ├─online <-- test data for online
│ │ └─test <-- test data for test
│ ├─screenshot <-- Failure screenshot
│ └─src
│ └─main
│ └─java
│ └─com.quanql.test
│ ├─androidui
│ │ ├─base <-- Android-specific base class, extend from the base of uitest_core
│ │ ├─page <-- page object
│ │ └─testcase <-- test case
│ └─perfutils <-- Android performance test util
├─uitest_core
│ └─src
│ └─main
│ ├─java
│ │ └─com.quanql.test
│ │ └─core
│ │ ├─base
│ │ │ ├─BaseOpt.java <-- base class. such as click, type, findelement,screenShot etc.
│ │ │ ├─BasePage.java <-- page object base class
│ │ │ ├─BaseTest.java <-- test case base class. manage TestNG life cycle
│ │ │ └─DriverFactory.java <-- driver factory, web and android and other drivers are here
│ │ ├─listener
│ │ └─utils
│ └─resources <-- slf4j config file is here
└─uitest_web
└─src
└─main
├─java
│ └─com.quanql.test
│ └─webui
│ ├─base <-- web-specific base class, extend from the base of uitest_core
│ ├─page
│ └─testcase
└─resources <-- chromedriver is here
```
# Architecture Diagram
![proj frame](/docs/images/project-frame.png)
# Write test cases step by step
## 1. Web UI
### Find Elements
1. Open browser, i.e. Chrome, open the url
2. Click F12 to open up the `DevTools` window, find elements by it. Relative cssSelector expression is recommended, such
as, `button[aria-label='Google Search']`
### Write test cases
+ page demo: See more details in `DemoBaiduPage.java` of uitest_web
+ case demo: See more details in `Demo163Test.java` of uitest_web
### Run test cases
1. configure `config.properties`
+ driver.type=chrome, firefox, iOSSafari
+ running.type=local (Standalone mode), remote (hub-node mode)
+ remote.address=the hub server url, only used as `running.type=remote`
## 2. iPhone UI
### Compile the application under test
1. Premise: Ensure that xcode can compile the app under test successfully, and verify the app's basic functions in the
simulator
2. Update the code
3. Compile the app
```
> cd $APP_PATH
> xcodebuild -workspace quanqlAPP.xcworkspace -scheme quanql -configuration Debug -sdk iphonesimulator -arch x86_64
```
4. Generate compressed package, where **quanql.zip is the app under test**
```
> ditto -ck --sequesterRsrc --keepParent \`ls -1 -d -t ~/Library/Developer/Xcode/DerivedData/\*/Build/Products/Debug-iphonesimulator/*.app | head -n 1\` ~/quanql.zip
```
### Find Elements
1. On the `iOS settings` page of appium server, set `App Path` to the directory of the zip generated in the previous
step, then set `Force Device` and `Platform Version`
2. Click `launch`
3. Click `inspector`. The operation of finding element is similar with Android
4. Relative XPath expression is recommended, such
as, `Button("xpath=//UIAAlert[@name='prompt']//UIAButton[@name='OK']")`
### Write test cases
+ page demo: See more details in `LoginPage.java` of uitest_iphone
+ case demo: See more details in `DemoLoginTest.java` of uitest_iphone
### Run test cases
1. configure `config.properties`
+ remote.address=the path of appium server
+ app=the absolute path of appium server
2. appium client
+ on Mac, that means you can run client and appium server on the same Mac
+ OR, on PC, the client will send commands to the remote appium server, and then the cases are still run on appium
server
## 3. Android UI
Similar to **iPhone**.
## 4. H5
Similar to **web**. In configure `config.properties`, set `driver.type=H5` so as to run test cases on mobile emulation
mode in Chrome.
# Two ways to write test cases
I think the people involved in writing UI automation can be divided into two groups (although there may be teams that
don't have two groups, all work together) :
1. The first group: the people who write the underlying or basic functions. They may be responsible for writing the
common methods, identification and encapsulation elements in base. People in this group m
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
UI_automated_testing_framework_(and_examples),_sui_WebAndAppUITesting.zip (83个子文件)
WebAndAppUITesting-master
uitest_core
pom.xml 1KB
src
main
resources
logback.xml 4KB
java
com
quanql
test
core
utils
LogUtil.java 5KB
AssertUtil.java 506B
ConfigUtil.java 3KB
FileUtil.java 11KB
TimeUtil.java 2KB
AndroidIDUtil.java 3KB
Constant.java 1KB
element
Button.java 286B
Text.java 310B
BaseElement.java 4KB
Edit.java 468B
base
BasePage.java 854B
BaseTest.java 3KB
DriverFactory.java 10KB
BaseOpt.java 15KB
package-info.java 92B
listener
PowerEmailableReporter.java 24KB
RetryListener.java 1KB
TestngRetry.java 2KB
TestResultListener.java 3KB
testng.xml 551B
config.properties 569B
uitest_web
pom.xml 1KB
src
main
java
com
quanql
test
webui
base
WebBasePage.java 245B
WebBaseOpt.java 6KB
WebBaseTest.java 238B
testcase
Demo163Test.java 594B
page
DemoBaiduPage.java 1KB
testng.xml 446B
config.properties 495B
pom.xml 5KB
README.cn.md 14KB
LICENSE 34KB
uitest_android
pom.xml 1KB
src
main
java
com
quanql
test
androidperfutils
AndroidConstant.java 4KB
data
MemoryInfo.java 4KB
CpuInfo.java 4KB
PhoneInfo.java 3KB
FlowInfo.java 4KB
FrameInfo.java 5KB
AppInfo.java 4KB
package-info.java 82B
PerfMonitor.java 5KB
task
FlowTask.java 3KB
CpuTask.java 3KB
FrameTask.java 3KB
MemTask.java 3KB
ShellUtils.java 4KB
CommandResult.java 2KB
package-info.java 105B
androidui
base
AndroidBasePage.java 3KB
AndroidBaseTest.java 3KB
AndroidBaseOpt.java 7KB
testcase
DemoLoginTest.java 2KB
page
MainFramePage.java 2KB
LoginPage.java 3KB
TabHomePage.java 3KB
TabMyPage.java 2KB
SplashPage.java 1KB
app
demoapp-1.0.0-mapping.txt 2KB
testng.xml 756B
testdata
test
Login.csv 101B
online
Login.csv 105B
config.properties 1KB
uitest_iphone
pom.xml 1KB
src
main
java
com
quanql
test
iphoneui
base
IphoneBaseOpt.java 6KB
IphoneBaseTest.java 1KB
IphoneBasePage.java 3KB
testcase
DemoLoginTest.java 934B
page
MainFramePage.java 906B
LoginPage.java 866B
TabHomePage.java 164B
TabMyPage.java 331B
SplashPage.java 470B
testng.xml 521B
config.properties 1KB
docs
images
project-frame.png 137KB
uiautomatorviewer.png 161KB
appium-server-mac.png 46KB
.gitignore 976B
README.md 15KB
共 83 条
- 1
资源评论
好家伙VCC
- 粉丝: 2388
- 资源: 9142
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- alpaca中文指令参数数据集.zip
- LoRA-算法深度讲解
- com.fuck.android.rimet-11-0.4-beta5.zip
- Screenshot_20241118-195813.jpg
- Apple Watch 慕尼黑数据采集 - 你的灵魂,你的节拍!.zip
- D3cn数据集合.zip
- HTML 樱花主题个人网页
- DataX 是阿里巴巴集团内被广泛使用的离线数据同步工具,平台,实现包括 MySQL、Oracle、HDFS、Hive、OceanBase、HBase、OTS、ODPS 等各种异构数据源之间高.zip
- 独家整理算法书籍与训练题干货
- 1_ahw_附件1:实验报告模板(空白)241129185950.docx
- DataX是阿里云DataWorks数据集成的开源版本 .zip
- amesim电池热管理学习资料+附带模型(多个)
- 机械设计全自动卧式压簧机sw18可编辑非常好的设计图纸100%好用.zip
- 华为OD机试真题-斗地主之顺子-2024年OD统一考试(E卷)_外企德科后端笔试真题pdf.html.txt
- Genshin Impact原神语音数据集语音数据集.zip
- labview yolov8分类,目标检测,实例分割,关键点检测onnxruntime推理,封装dll, labview调用dll,支持同时加载多个模型并行推理,可cpu gpu, x86 x64位
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功