简体   繁体   中英

How can I run parallel tests with appium using selenium grid?

I tried up two different appium servers in my machine and start tests for iOS in one server and start Android tests in other. I tried execute too in two servers to tests in different iOS.

But problem is when I execute to two iOS the tests that should happen in iOS1 are happen in iOS to, not always, have times that run on iOS1 and shuffle and then are executed on iOS2, when not, all run into clutter. Then I can't do execute tests in parallel in this format.

For Android + iOS, only tests to iOS make do.

How can I execute my tests in parallel using appium with Ruby, if not possible running in parallel how can I run in line?

You need proper capabilities definition and request.

From my bit old notes (unfortunately for Android):

Stop/kill Selenium Server, all Appium instances and all tests (Ruby/Cucumber).

Start Selenium Server

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

Save 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"
  }
}

Make sure to change 80801 and 80802 to free ports for each device!

Run appium:

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

Where udid is what adb devices gives you and again change 80801

Check if device is registered correctly on http://127.0.0.1:4444/wd/console

And finally in ruby:

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

If I remember well requesting deviceName and/or version only works well. So if you start multiple nodes and specify deviceName and version correctly, you can then request it multiple time even in parallel. If you use wildcard * as in example above, it means any deviceName , so only version 7.0 is requested. Make sure run @T.quit to free device even if your test fail (put it in after hook).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM