【问题标题】:How can I run parallel tests with appium using selenium grid?如何使用 selenium 网格对 appium 运行并行测试?
【发布时间】:2019-01-13 12:03:16
【问题描述】:

我在我的机器上尝试了两台不同的 appium 服务器,并在一台服务器上启动 iOS 测试并在另一台服务器上启动 Android 测试。我也尝试在两台服务器上执行以在不同的 iOS 中进行测试。

但问题是,当我执行两个 iOS 时,应该在 iOS1 中进行的测试在 iOS 中发生,但并非总是有时间在 iOS1 上运行并随机播放,然后在 iOS2 上执行,否则,所有测试都会变得混乱.然后我不能以这种格式并行执行测试。

对于 Android + iOS,仅对 iOS 进行测试即可。

如何使用 appium 和 Ruby 并行执行我的测试,如果无法并行运行,我该如何在线运行?

【问题讨论】:

  • 说到Appium和ruby,你用的是Cucumber-Gherkin-Ruby设置吗?
  • @VighneshPai,我在用这套

标签: ruby selenium cucumber appium selenium-grid


【解决方案1】:

您需要适当的能力定义和请求。

来自我的旧笔记(不幸的是对于 Android):

停止/杀死 Selenium 服务器、所有 Appium 实例和所有测试(Ruby/Cucumber)。

启动 Selenium 服务器

java -jar selenium-server-standalone-3.6.0.jar -role hub

保存SM_G900F.json

{
  "capabilities":
  [
    {
      "applicationName":"SM_G900F",
      "browserName":"android",
      "deviceName":"SM_G900F",
      "version":"7.0",
      "maxInstances":1,
      "platform":"Android"
    }
  ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"http://127.0.0.1:80801/wd/hub",
    "maxSession":6,
    "port":"80801",
    "bootstrap-port":"80802",
    "host": "localhost",
    "register": true,
    "registerCycle": 5000,
    "hubPort": "4444",
    "hubHost": "localhost"
  }
}

确保将8080180802 更改为每个设备的空闲端口!

运行appium:

appium --nodeconfig /path_to/SM_G900F.json -p 80801 --default-capabilities '{"udid":"BOGAA1BBB412"}'

udid 是 adb devices 为您提供的,然后再次更改 80801

检查设备是否在http://127.0.0.1:4444/wd/console上正确注册

最后是红宝石:

require 'appium_lib'
opts_dut = {
    caps: {
        platformName: :android,
        version: '7.0',
        deviceName: '*',
        appPackage: 'your.package',
        appActivity: 'your.MainActivity',
        noReset: true,
        autoLaunch: false,
        automationName: 'uiautomator2'
    },
    appium_lib: {
        server_url: 'http://127.0.0.1:4444/wd/hub',
        wait_timeout: 300,
        wait_interval: 100,
        newCommandTimeout: 3000
    }
}
@T = Appium::Driver.new(opts_dut, true).start_driver
@T.find_elements(:uiautomator, "new UiSelector().textMatches(\"(?is).*SEND.*\"))")
puts @T.page_source
@T.quit

如果我记得很清楚,请求 deviceName 和/或 version 效果很好。因此,如果您启动多个节点并正确指定deviceNameversion,那么您甚至可以并行多次请求它。如果您使用通配符*,如上例所示,则表示任何deviceName,因此只请求version 7.0。即使您的测试失败,请确保运行@T.quit 以释放设备(将其放入挂钩后)。

【讨论】:

    猜你喜欢
    • 2016-09-25
    • 1970-01-01
    • 1970-01-01
    • 2017-07-22
    • 2020-09-30
    • 2020-11-06
    • 2021-10-18
    • 2017-05-25
    • 1970-01-01
    相关资源
    最近更新 更多