appium grid分布式环境搭建

说起grid,了解selenium的人肯定知道,他就是分布式的核心。原理是简历中心hub,然后配置node,在hub上运行服务时,会去node上执行相关操作,类似于Jenkins上的节点操作。

那么appium如何搭建grid环境呢,其实和selenium类似,首先搭建hub:

一、搭建hub

        首先下载selenium-server-standalone-<version>.jar文件,地址:http://selenium-release.storage.googleapis.com/index.html。这里使用的是selenium-server-standalone-3.4.0.jar

        下载完成后直接在jar目录下运行:java -jar selenium-server-standalone-3.4.0.jar -p 4444 -role hub

访问:127.0.0.1:4444/grid/console


        表示hub启动。

二、启动node

        首先新建test.json文件,内容如下:

{
  "capabilities": [
    {
      "deviceName": "test",
      "version": "4.4.2",
      "maxInstances": 3,
      "platform": "ANDROID",
      "browserName": "chrome"
    }
  ],
  "configuration":
    {
        "cleanUpCycle":"2000",
        "timeout":"30000",
        "proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "url":"http://127.0.0.1:4723/wd/hub",  //appiumserver地址,即node地址
        "host":"127.0.0.1",
        "port":"4723",           //节点机服务端口
        "maxSession":"1",
        "register":true,
        "registerCycle":"5000",
        "hubPort":"4444",     //hub端口
        "hubHost":"192.168.4.41"      //hub地址
    }
}

    然后执行命令:appium -p 4723 -bp 4724 --nodeconfig test.json。

    

    在hub的启动服务后台能看到注册信息:


另外查看127.0.0.1:4444/grid/console页面可以看到节点机信息:


表示节点机注册成功,在运行appium服务时:

driver = webdriver.Remote('http://节点机ip:端口/wd/hub', desired_caps)
这里需要注意hub和node的ip,不要混淆。我这里使用的hub和node在同一机器上,实际使用时,按实际情况配置即可。

猜你喜欢

转载自blog.csdn.net/ljl6158999/article/details/80803239