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()  # 阻塞上下文环境的进程,直到调用此方法的进程结束

      

  • 相关阅读:
    http协议
    三次握手四次挥手的原理
    mmap
    I/O多路复用之poll
    I/O多路转接之select
    自旋锁、文件锁、大内核锁
    网络基础(一)
    线程同步之(信号量)
    进程与线程的简单理解
    内存溢出——程序员必备网站
  • 原文地址:https://www.cnblogs.com/Cc905/p/13926336.html
Copyright © 2011-2022 走看看