Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用appium和Python在多个设备上运行一个测试_Python_Appium_Selenium Grid - Fatal编程技术网

如何使用appium和Python在多个设备上运行一个测试

如何使用appium和Python在多个设备上运行一个测试,python,appium,selenium-grid,Python,Appium,Selenium Grid,我正在使用Python语言尝试Appium。我有一个简单的Android Python脚本(只需打开应用程序,查找文本并断言此文本)。 我想在几个设备上运行这个测试 我已经做过的: 我已经创建了两个Android模拟器。运行Selenium网格中心。为每个emulator创建两个配置文件,并运行2台Appium服务器: appium --address 127.0.0.1 --port 4721 -bp 2253 --udid emulator-5554 --nodeconfig C:\Sele

我正在使用Python语言尝试Appium。我有一个简单的Android Python脚本(只需打开应用程序,查找文本并断言此文本)。 我想在几个设备上运行这个测试

我已经做过的:

我已经创建了两个Android模拟器。运行Selenium网格中心。为每个emulator创建两个配置文件,并运行2台Appium服务器:

appium --address 127.0.0.1 --port 4721 -bp 2253 --udid emulator-5554 --nodeconfig C:\SeleniumGrid\Android\emulator-5554.json
枢纽

Appium服务器:

appium --address 127.0.0.1 --port 4721 -bp 2253 --udid emulator-5554 --nodeconfig C:\SeleniumGrid\Android\emulator-5554.json

我的JSON配置文件:

第一:

{  "capabilities":
      [
        {
          "deviceName": "emulator-5554",
          "browserName":"Browser", 
          "version":"6.1",
          "maxInstances": 1,
          "platform":"ANDROID"
        }
      ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"http://127.0.0.1:4721/wd/hub",
    "host": "127.0.0.1",
    "port": 4721,
    "maxSession": 10,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": "127.0.0.1"
  }
}
第二:

{  "capabilities":
      [
        {
          "browserName":"Browser",  
          "deviceName": "emulator-5556",
          "version":"4.4.4",
          "maxInstances": 1,
          "platform":"ANDROID"
        }
      ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"http://127.0.0.1:4722/wd/hub",
    "host": "127.0.0.1",
    "port": 4722,
    "maxSession": 10,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": "127.0.0.1"
  }
}
以及我的设置方法:

def setUp(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = 'platformVersion'
        desired_caps['deviceName'] = 'deviceName'

        desired_caps['app'] = 'oneDo.apk'

        self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps)
如何在多个设备上运行此测试?接下来我该怎么办? 也许使用一些框架。蝙蝠是哪一种,如何?我到处都问过这个问题,什么都读过

我一直都知道,要创建第二个脚本test2.py,但是要为另一个设备创建。因此,每个设备的每个脚本。但我认为这不是一个正确的方法

def setUp(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = 'platformVersion'
        desired_caps['deviceName'] = 'deviceName'

        desired_caps['app'] = 'oneDo.apk'

        self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps)