- 简介
Kite是一个用于测试WebRTC跨浏览器互操作性的测试引擎。
- 支持编写跨平台的自动化的Java或JavaScript测试脚本
- 支持Linux、Windows、Mac、iOS和Android系统
- 支持Chrome、Firefox、Safari、Opera、MicroftEdge等主流Web浏览器
- 支持Mobile Native Apps on Android, iOS
- 支持Desktop Native Apps on Windows and MacOS
- 支持Electron Apps
工作原理:KITE构建Selenium(automates browsers)测试环境,加载浏览器WebDriver,运行用户编写的测试步骤TestStep和预期结果检测TestCheck,将测试结果保存至Allure(开源的测试报告框架),并可通过浏览器进行查看。
Selenium Grid是一个分布式测试框架,如下图所示:
- 安装
- 依赖
- Windows
- 安装Git
- 安装JDK:下载安装包,安装后设置环境变量JAVA_HOME,并将%JAVA_HOME%\bin添加到PATH环境变量中
- 安装Maven:下载编译好的zip文件,解压;添加环境变量MAVEN_HOME,并将%MAVEN_HOME%\bin添加到PATH环境变量中;执行mvn -version检查安装结果

修改conf/settings.xml,添加阿里的Maven源镜像

- 安装Kite2.0
- 从github下载源码,存放源码的路径中不能有空格。进入KITE目录。
- 执行bat,用于设置KITE_HOME环境变量以及添加工具脚本到PATH中。根据脚本提示安装selenium local grid,注意默认配置中浏览器版本是否和本机匹配,若不一致,需要修改scripts\windows\gridCofnig.bat。


这个过程可能由于网络原因导致下载失败,需要手动下载相关文件并放到相应的目录中:
Selenium.jar:下载,然后复制jar到KITE\localGrid\selenium.jar
ChromeDriver: 下载,然后解压复制到KITE\localGrid\chrome\chromedriver.exe
GeckDriver:下载,然后解压复制到KITE\localGrid\firefox\geckodriver.exe
然后再运行一次configure.bat。成功后会看到下边的几个窗口:
打开http://localhost:4444/grid/console,可以看到两个Selenium节点


- 运行Sample
- 首先保证local grid已经在运行,打开http://localhost:4444/grid/console来检查是否运行。若没有,手动运行KITE\localGrid\startGrid.bat
- 进入KITE-AppRTC-Test目录,执行r configs\iceconnection.local.config,会打开两个Chrome浏览器,同时访问https://appr.tc。该测试用例会检测两个用户的链接状态和视频连通状态。
- 测试结束后,执行a,可在浏览器中查看测试结果
- CentOS
- IceConnectionTest解析
- 用例说明:打开两个浏览器,进入appr.tc同一房间,获取连接状态和sdp信息
- 配置:iceconnection.local.config.json
{
“name”: “IceConnectionTest JS”,
“callable”: true,
“remotes”: [ //配置SeleniumGrid,可以是local、saucelabs
//browserstack、testingbot中的一个或多个
{
“type”: “local”,
“remoteAddress”: “http://localhost:4444/wd/hub”
}
],
“tests”: [
{
“name”: “IceConnectionTest”,
“tupleSize”: 2,
“description”: “This test check the ICEConnection state between two browsers communicating via appr.tc”,
“testImpl”: “IceConnectionTest.js”, //测试用例主脚本
“payload” : { //测试用例所需参数
“url”: “https://appr.tc”,
“testTimeout”: 60,
“statsCollectionTime”: 3,
“statsCollectionInterval”: 1,
“getStats”: true,
“selectedStats”: [
“candidate-pair”,
“inbound-rtp”,
“outbound-rtp”,
“track”
]
}
}
],
“browsers”: [ //浏览器配置
{
“browserName”: “chrome”,
“version”: “73”,
“platform”: “WINDOWS”,
“flags”: []
}
]
}
const {TestUtils, WebDriverFactory, KiteBaseTest, Status} = require(‘kite-common’);
const globalVariables = TestUtils.getGlobalVariables(process);
// Steps & checks
const {OpenAppUrlStep, ConnectToAppRoomStep, GetStatsStep} = require(‘./steps’);
const {PeerConnectionCheck, RemoteVideoDisplayCheck} = require(‘./checks’);
// KiteBaseTest config
const capabilities = require(globalVariables.capabilitiesPath);
const payload = require(globalVariables.payloadPath);
class IceConnectionTest extends KiteBaseTest {
constructor(name, globalVariables, capabilities, payload) {
super(name, globalVariables, capabilities, payload);
}
async testScript() {
try {
this.driver = await WebDriverFactory.getDriver(this.capabilities, this.capabilities.remoteAddress);
let openAppUrlStep = new OpenAppUrlStep(this);
await openAppUrlStep.execute(this);
let connectToAppRoomStep = new ConnectToAppRoomStep(this);
await connectToAppRoomStep.execute(this);
let peerConnectionCheck = new PeerConnectionCheck(this);
await peerConnectionCheck.execute(this);
let remoteVideoDisplayCheck = new RemoteVideoDisplayCheck(this);
await remoteVideoDisplayCheck.execute(this);
let getStatsStep = new GetStatsStep(this);
await getStatsStep.execute(this);
// End of Test reportWebDriverUtils
this.report.setStopTimestamp();
} catch (error) {
console.log(error);
} finally {
await this.driver.quit();
}
this.reporter.generateReportFiles();
let value = this.report.getJsonBuilder();
TestUtils.writeToFile(this.reportPath + ‘/result.json’, JSON.stringify(value));
}
}
module.exports = IceConnectionTest;
var test = new IceConnectionTest(‘IceConnection Test’, globalVariables, capabilities, payload);
test.testScript();
- TestSteps
- OpenAppUrlStep//open appr.tc
- ConnectToAppRoomStep//根据当前时间生成roomId,在tc页面设置//roomId,并进入房间
- PeerConnectionCheck//通过js获取iceConnectionState
- RemoteVideoDisplayCheck
- GetStatsStep//获取sdp信息
- Kite框架分析
- KiteBaseTest
- name, numberOfParticipant, capabilities
- report(AllurTestReport), reporter //测试报告相关
- payload //测试用例配置传入的参数
- testScript() //子类必须实现此函数:构造TestStep并调用execute()
- TestStep
- dsescription
- report(AllurTestReport)
- execute() //调用setp(),并设置report信息和状态
- skip(), finish()
- step() //子类必须实现此函数:实现本测试步骤的逻辑
近期评论