zoukankan      html  css  js  c++  java
  • 十、appium多进程启动设备

      可以使用多线程或者多进程实现,这里使用的是多进程。修改appium监听的端口号,否则会启动失败。

    # user/bin/env python
    # -*- coding:utf-8 -*-
    # __author__ = "Cc"
    
    from appium import webdriver
    import multiprocessing
    
    desired_caps_a = {'platformName': "Android", 'platformVersion':  "", 'deviceName': "", 'appPackage': "", 'appActivity': "",
                      'noReset': True, 'unicodeKeyboard': True, 'resetKeyboard': True}
    desired_caps_b = {'platformName': "Android", 'platformVersion':  "", 'deviceName': "", 'appPackage': "", 'appActivity': "",
                      'noReset': True, 'unicodeKeyboard': True, 'resetKeyboard': True}
    host_address_a = "http://localhost:4723/wd/hub"
    host_address_b = "http://localhost:4727/wd/hub"
    
    
    def start_mobile(desired_caps, host_address):
    
        """多进程启动设备
        :desired_caps:启动手机端信息
        :host_address:appium服务器端信息
        :return:driver
        """
        driver = webdriver.Remote(host_address, desired_caps)
        return driver
    
    
    desired_processes = []
    
    
    if __name__ == '__main__':
        desired_process1 = multiprocessing.Process(target=start_mobile, args=(desired_caps_a, host_address_a))
        desired_processes.append(desired_process1)
        desired_process2 = multiprocessing.Process(target=start_mobile, args=(desired_caps_b, host_address_b))
        desired_processes.append(desired_process2)
        for process in desired_processes:
            process.start()
        for process in desired_processes:
            process.join()  # 阻塞上下文环境的进程,直到调用此方法的进程结束

      

  • 相关阅读:
    C#读写txt文件的两种方法介绍
    C#委托的介绍(delegate、Action、Func、predicate)
    C#邮件发送
    ASP.NET 文件上传于下载
    关于Virtual Box虚拟机里的系统不能启动的解决方法
    unity的yield
    unity文件路径
    手机上的unity路径
    readonly
    unity延迟加载图片
  • 原文地址:https://www.cnblogs.com/Cc905/p/13926336.html
Copyright © 2011-2022 走看看