与Appium& amp;并行测试硒栅 [英] parallel test with appium & selenium grid

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

问题描述

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

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.

是否必须提供一些参数才能将其设置为parallel?

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

第一步:在您的环境变量中添加appium(.. \ Appium \ node_modules.bin)步骤2:为每个节点制作不同的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

对于node1

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& amp;并行测试硒栅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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