Appium with Python如何以并行模式运行脚本?

2024-04-24 17:30:49 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,有人能帮我启动并行执行的测试脚本吗?

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

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

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

第一步:

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

第2步:

^{pr2}$

第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-my 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-my 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": ""
})

Tags: org脚本jsontruehostportseleniumtimeout