配置讲解
配置所在的文件是wdio.conf.ts(如果你用的js,就是wdio.conf.js),一般新建的项目它的路径是在./test/wdio.conf.ts,这个文件是webdriver.io的所有配置信息.
配置一: capabilities
1.介绍
此配置主要配置的是你的连接信息,比如:你要连接chrome浏览器,你就需要传入browserName:‘chrome’,这样它就会去连接chrome浏览器.
注意: 它只是配置连接信息,并不是启动一个chrome浏览器或是去启动chromedriver
2.配置连接单个服务
export const config: Options.Testrunner = {
......
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 5,
//
browserName: 'chrome',
acceptInsecureCerts: true,
// If outputDir is provided WebdriverIO can capture driver session logs
// it is possible to configure which logTypes to include/exclude.
// excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
// excludeDriverLogs: ['bugreport', 'server'],
'goog:chromeOptions': {
args: [
// '--headless',
'--disable-infobars',
'--no-sandbox',
'--disable-gpu',
'--window-size=1024,768',
].concat(isCI ? ['--headless'] : []) // run in headless mode on the CI server,
}
}],
......
}
3.配置连接多个服务
export const config: Options.Testrunner = {
......
capabilities: {
// 这里面就是配置你需要连接的服务
// 连接chorme浏览器
a: {
prot: 9515,
path: "/",
capabilities: {
browserName: 'chrome'
}
},
// 连接appium
b: {
prot : 4723,
path: '/wd/hub',
capabilities: {
'platformName': 'ios',
......
}
}
}
......
}
4.如果你觉得这些配置有些麻烦,那可以去下面给的网站,根据需求自动生成配置
https://saucelabs.com/platform/platform-configurator
配置二: services
1.介绍
此配置主要是配置你需要webdriver.io帮你启动的服务,比如chromedriver,appium,启动这些服务时,要安装对应的依赖,同时如果你用这种方式帮你启动的话,你无需在向之前一样,chrome更新后去重新下载chromedriver.
2.配置单个服务
export const config: Options.Testrunner = {
......
// 启动chromedriver
services: [‘chromedrvier’]
......
}
3.配置多个服务
export const config: Options.Testrunner = {
......
// 启动chromedriver
services: [["chromedriver", {
port: 9515,
hostname: "localhost"
}], ["appium", { port: 4723, hostname: "localhost"}]],
......
}