我试图在多台设备上并行运行appium脚本。为此我尝试使用selenium网格设置appium服务器(appium v1.6.3)。
我遵循的方法: 1.创建Hub.json文件
为两个设备创建了nodeconfig json文件
将所有这些文件与selenium-server-standalone-2.53.0.jar文件一起放在一个文件夹中
在终端中,运行命令:
java -jar selenium-server-standalone-2.53.0.jar -role hub -hubConfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/hub.json
然后运行nodeconfig,
节点appium --nodeconfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/iPadmini.json -p 4723
我在这里看到以下错误:
CH0006s-Mac-mini:lib CH0006$ node appium --nodeconfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/iPadmini.json -p 4040
/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'loads';
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
注意:Appium.js不存在于bin文件夹中,因此我使用了libium文件夹的路径,其中存在appium.js。
配置:
Hub.json:
{
"newSessionWaitTimeout" : -1,
"timeout" : 30000,
"capabilityMatcher" : "org.openga.grid.internal.utils.DefaultCapabilityMatcher",
"servlets" : [],
"maxSession" : 5,
"prioritizer" : null,
"host" : null,
"throwOnCapabilityNotPresent" : true,
"nodePolling" : 5000,
"CleanUpCycle" : 5000,
"browserTimeout" : 90000,
"port" : 4444
}
device1.json:
{
"configuration" : {
"registerCycle" : 5000,
"timeout" : 600000,
"maxSession" : 1,
"cleanCycle" : 5000,
"nodeTimeout" : 120,
"hubHost" : "localhost",
"host" : "localhost",
"nodePolling" : 2000,
"hubPort" : 4444,
"role" : "node",
},
"capabilities" : [
{
"platformName" : "iOS",
"version" : "10.1.1",
"maxInstances" : 4,
"deviceName" : "iPad mini",
"browserName" : "iOS",
"platform" : "MAC"
}
]
}
答案 0 :(得分:1)
selenium-server-standalone-2.53.0.jar
放在同一个文件夹java -jar selenium-server-standalone-2.53.0.jar -role hub
,转到jar所在的文件夹ios_webkit_debug_proxy -c 7f5bc36b71a4d44161c128464c9d516d2ec3af94:27755 -d
在其他终端窗口中 - 转到appium所在的路径 - 然后运行
节点appium --session-override --nodeconfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/node3.json --show-ios-log --tmp / Users / CH0006 / Proj_Documentation / Testing / Appium / selenium_config / device2 -p 4730 --bootstrap-port 4467 --udid 7f5bc36b71a4d44161c128464c9d516d2ec3af94 --webkit-debug-proxy-port 27755 --full-reset --native-instruments-lib --safari> /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/iphone6s.txt
注意:如果您使用appium v1.6
或更高版本 - 请更好地使用./node_modules/.bin/appium
代替node appium
(它会自动找到appium路径)
6. Create one testng xml file in project and write code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://www.testng.org/testng-1.0.dtd">
<suite name="Default Suite" parallel="tests">
<test verbose="2" name="Device1">
<parameter name="Device_ID" value="6f307db6c72271c87b5936cf08aac61134001cc4" />
<parameter name="wdaPort" value="8200" />
<classes>
<class name="SampleAppTest.SampleAppScan">
<methods> <include name="ID1Scan"/> </methods>
</class>
</classes>
</test>