与 appium & 的平行测试硒网格 [英] parallel test with appium & selenium grid

查看:24
本文介绍了与 appium & 的平行测试硒网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 appium & 在 2 个设备上运行并行测试selenium grid 但由于某种原因它只在第一个节点服务器(和第一个设备)上运行,但在第二个服务器上什么也没有发生.

I'm trying to run parallel test on 2 devices using appium & selenium grid but for some reason it runs only on the first node server (and first device) but nothing happen on the second server.

此外,如果我关闭第一台服务器并运行测试,那么测试会在第二台服务器上运行,因此服务器应该没有任何问题.

Also if I'm shutting down the first server and run the test then the test run on the second server so there shouldn't be any issue with the servers.

是否需要提供一些参数才能将其设置为并行?

Is there some parameter that I have to give in order to set it to parallel ?

感谢您的帮助!

这是我的文件:

第一个服务器json文件:

First server json file :

{
  "capabilities":
  [
    {
      "browserName": "SamsungS6",
      "deviceName": "04157df40862d02f",
      "version":"6.0.1",
      "maxInstances": 3,
      "platform":"ANDROID"
    }
  ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"http://localhost:4491/wd/hub",
    "host": "localhost",
    "port": 4491,
    "maxSession": 5,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4433,
    "hubHost": "localhost"
   }
}

第二个服务器json文件:

Second server json file :

{
  "capabilities":
  [
    {
      "browserName": "OnePlusOne",
      "deviceName": "14b2b276",
      "version":"6.0.1",
      "maxInstances": 3,
      "platform":"ANDROID",
      "platformName":"ANDROID"
    }
  ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"http://localhost:4490/wd/hub",
    "host": "localhost",
    "port": 4490,
    "maxSession": 5,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4433,
    "hubHost": "localhost"
  }
}

运行硒网格:

java -jar selenium-server.jar -role hub -port 4433 

运行第一个场景

node.exe node_modules\appium\bin\appium.js --nodeconfig myfirstscenario.json -p 4490 -U 14b2b276 -bp 5490 --chromedriver-port 6490

运行第二个场景

node.exe node_modules\appium\bin\appium.js --nodeconfig mysecondscenario.json -p 4491 -U 04157df40862d02f -bp 5491 --chromedriver-port 6491

测试

@BeforeTest(alwaysRun = true)
public void setUp(){

    try {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "ANDROID");
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "");
        capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, appPackage);
        capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, appActivity);

        driver = new AndroidDriver(new URL("http://localhost:4433/wd/hub"), capabilities);
        new WebDriverWait(driver, 60);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

}

@Test
public void test(){
    System.out.println("hello world");

    try {
        sleep(6000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}


@AfterTest(alwaysRun = true)
public void closeDriver(){
    driver.quit();
}

推荐答案

我也遇到了同样的问题,但是通过

i also faced the same issue but got resolved by

Step1: 在你的环境变量中添加 appium (.. \Appium\node_modules.bin)Step2:为每个节点制作不同的json.

Step1: add the appium (.. \Appium\node_modules.bin) in you environment variable Step2: make the differen json for the each node.

对于节点 1

 {   "capabilities":
    [
      {
        "version":"6.0",
        "maxInstances": 1,
        "platform":"ANDROID",
        "newCommandTimeout":"30",
        "deviceReadyTimeout":5
      }
    ],   "configuration":   {
    "cleanUpCycle":2000,
    "timeout":10800,
    "url":"http://127.0.0.1:4723/wd/hub",
    "host": "127.0.0.1",
    "port": 4723,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 1,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": "127.0.0.1"   } }

对于节点 2

 {
  "capabilities":
    [
      {
        "version":"5.0.2",
        "maxInstances": 1,
        "platform":"ANDROID",
        "newCommandTimeout":"30",
        "deviceReadyTimeout":5
      }
    ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":10800,
    "url":"http://127.0.0.1:4733/wd/hub",
    "host": "127.0.0.1",
    "port": 4733,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 1,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": "127.0.0.1"
  }
}

现在为了运行我在批处理文件中制作的集线器

now for to run the hub i have made that in a batch file

java -jar %cd%\selenium-server-standalone-2.52.0.jar -role hub http://127.0.0.1:4444/grid/console

对于节点 1

appium -a 127.0.0.1 -p 4723 --no-reset --bootstrap-port 4728 -U 192.168.56.101:5555 --nodeconfig %cd%\5555appium1.json

和节点 2

appium -a 127.0.0.1 -p 4733 --no-reset --bootstrap-port 4738 -U 4d00af03525c80a1 --nodeconfig %cd%\4d00appium2.json

并在您的代码中添加 deviceName:'您的设备名称,它出现在 cmd 中的 adb 设备上'

and in you code add the deviceName:'your device name which comes on adb devices in cmd'

这对我很有用.

这篇关于与 appium & 的平行测试硒网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆