Selenium Grid
通過
--nodeconfig
這個服務端參數,可以将 appium server 注冊到本地的 Selenium grid (Grid 的配置文檔)
> appium --nodeconfig /path/to/nodeconfig.json
# 或者使用源檔案執行
> node . --nodeconfig /path/to/nodeconfig.json
在 node 的配置檔案裡,你需要定義
browserName
,
version
和
platform
。 通過這些參數,selenium grid 會将你的測試定向到正确的裝置上去。你還需要配置你的
host
詳細資訊和
selenium grid
的詳細資訊。你可以在 這裡 找到詳細的參數清單和描述資訊。
一旦你啟動了 appium 伺服器并且在 grid 裡注冊了資訊,就可以在 grid 控制台發現你的裝置:
"http://<grid-ip-adress>:<grid-port>/grid/console"
Grid node的配置檔案例子
{
"capabilities":
[
{
"browserName": "<e.g._iPhone5_or_iPad4>",
"version":"<version_of_iOS_e.g._7.1>",
"maxInstances": 1,
"platform":"<platform_e.g._MAC_or_ANDROID>"
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://<host_name_appium_server_or_ip-address_appium_server>:<appium_port>/wd/hub",
"host": <host_name_appium_server_or_ip-address_appium_server>,
"port": <appium_port>,
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"hubPort": <grid_port>,
"hubHost": "<Grid_host_name_or_grid_ip-address>"
}
}
可以在 這裡檢視有效的 platform 參數。
如果沒有給出
url
、
host
和
port
,配置會自動指向
localhost:whatever-port-Appium-started-on
。
如果你的 Appium Server 和 Selenium Grid 沒有運作在同一台機器上,為確定 Selenium Grid 連接配接正常,請在你的
host
&
url
上使用外部域名或 IP 位址,而不是 localhost 和 127.0.0.1