Appium with Python - 如何在并行模式下运行脚本?

时间:2016-11-03 15:00:53

标签: python selenium-webdriver appium selenium-grid python-appium

嗨,有人可以帮助我在并行执行中启动测试脚本吗?

如何在脚本中配置Desire功能和webdriver实例?

我有用Python编写的appium测试脚本和unittest。

我的网格已启动并正在运行,但测试脚本仅在一台设备上启动:/ (如果我更改设备名称,它将在其他设备上启动,但如何在两台设备上同时启动?)

第1步:

java -jar selenium-server-standalone-3.0.1.jar -role hub -hubConfig C:\selenium\hubconfig.json

第2步:

appium --nodeconfig C:\selenium\nodeconfig1.json -p 4732 -bp 5724

第3步:

appium --nodeconfig C:\selenium\nodeconfig3.json -p 4743 -bp 5744

ad1 - 我的hubconfig.json:

{
  "host": "127.0.0.1",
  "port": 4444,
  "newSessionWaitTimeout": 1,
  "servlets" : [],
  "prioritizer": null,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": true,
  "nodePolling": 5000,

  "cleanUpCycle": 5000,
  "timeout": 300000,
  "maxSession": 4
}

ad2 - 我的nodeconfig1.json:

{
  "capabilities":
      [
        {
          "browserName": "Samsung Galaxy S7",
          "version":"6.0.1",
          "maxInstances": 1,
          "platform":"ANDROID"
        }
      ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"http://127.0.0.1:4732/wd/hub",
    "host": "127.0.0.1",
    "port": 4732,
    "maxSession": 1,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": "127.0.0.1"
  }
}

ad3 - 我的nodeconfig3.json:

{
  "capabilities":
      [
        {
          "browserName": "QUANTUM_2_400",
          "version":"4.4.2",
          "maxInstances": 1,
          "platform":"ANDROID"
        }
      ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"http://127.0.0.1:4743/wd/hub",
    "host": "127.0.0.1",
    "port": 4743,
    "maxSession": 1,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": "127.0.0.1"
  }
}

之后我的selenium网格启动并运行两个appium节点和两个Android设备,但是我应该在测试脚本中包含什么来并行运行它?

目前我正在尝试这样的事情:

self.driver = webdriver.Remote(
command_executor="http://localhost:4444/wd/hub",
desired_capabilities={
                "platformName": "ANDROID",
                "platformVersion": "4.4.2",
                "deviceName": "QUANTUM_2_400",
                "app": PATH("...apk"),
                "appPackage": "",
                "appActivity": ""
})

0 个答案:

没有答案