appium+python一个脚本同时运行在多台android设备
来源:互联网 发布:ps软件收费吗 编辑:程序博客网 时间:2024/06/03 17:40
# -*- coding:utf-8 -*-
from appium import webdriver;
import subprocess
import time
import os
import login_Activity
import threading;
from selenium.webdriver.support.ui import WebDriverWait;
PATH=lambda p:os.path.abspath(os.path.join(os.path.dirname(__file__),p))
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4'
desired_caps['deviceName'] = ''
desired_caps['app'] = PATH('C:\\Users\\butel\\Desktop\\hvs_s175_v2.6.68.310-201709111846.apk')
# desired_caps['appPackage'] = 'com.tencent.mm'
# desired_caps['appActivity'] = 'com.tencent.mm.ui.LauncherUI'
desired_caps['unicodeKeyboard'] = 'True'
desired_caps['resetKeyboard'] = 'True'
subprocess.call('start /b taskkill /f /t /im node.exe', shell=True, stdout=open('D:\log\\shasi.log', 'w'), stderr=subprocess.STDOUT)
ip = ['192.168.8.100', '192.168.8.103']
tt = []
def sever(ip):
for i in range(len(ip)):
host = '127.0.0.1'
cmd = 'start /b appium -a ' + host + ' -p ' + str(4723 + 2 * i) + \
' --command-timeout 500 --automation-name Appium -U ' + ip[i] + ':' + str(5555 + i)
print cmd
time.sleep(2)
# 注释掉的
# subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subprocess.call(cmd, shell=True, stdout=open('D:\log\\log.log', 'w'), stderr=subprocess.STDOUT)
time.sleep(30)
driver = webdriver.Remote('http://localhost:' + str(4723 + 2 * i) + '/wd/hub', desired_caps)
hh = Ni(driver)
t = threading.Thread(target=hh.login)
tt.append(t)
class Ni():
def __init__(self, driver):
self.driver = driver
def login(self):
time.sleep(5)
print 111111111
for j in range(3):
# self.cgw = self.driver.find_element_by_id("cn.redcdn.hvs:id/Login_numdemo_edit");
# time.sleep(3)
# self.cgw.click();
# time.sleep(3)
login_Activity.login_phone(self)
# self.bum = self.driver.find_element_by_id("com.tencent.mm:id双击查看原图n")
# self.bum.send_keys('12345678')
# time.sleep(2)
#
# self.gz = self.driver.find_element_by_id("com.tencent.mm:id双击查看原图");
# self.gz.send_keys('jho');
# time.sleep(2)
print 2222222222
# self.driver.keyevent(4)
self.driver.quit()
if __name__ == '__main__':
sever(ip)
time.sleep(2)
for i in tt:
i.start()
from appium import webdriver;
import subprocess
import time
import os
import login_Activity
import threading;
from selenium.webdriver.support.ui import WebDriverWait;
PATH=lambda p:os.path.abspath(os.path.join(os.path.dirname(__file__),p))
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4'
desired_caps['deviceName'] = ''
desired_caps['app'] = PATH('C:\\Users\\butel\\Desktop\\hvs_s175_v2.6.68.310-201709111846.apk')
# desired_caps['appPackage'] = 'com.tencent.mm'
# desired_caps['appActivity'] = 'com.tencent.mm.ui.LauncherUI'
desired_caps['unicodeKeyboard'] = 'True'
desired_caps['resetKeyboard'] = 'True'
subprocess.call('start /b taskkill /f /t /im node.exe', shell=True, stdout=open('D:\log\\shasi.log', 'w'), stderr=subprocess.STDOUT)
ip = ['192.168.8.100', '192.168.8.103']
tt = []
def sever(ip):
for i in range(len(ip)):
host = '127.0.0.1'
cmd = 'start /b appium -a ' + host + ' -p ' + str(4723 + 2 * i) + \
' --command-timeout 500 --automation-name Appium -U ' + ip[i] + ':' + str(5555 + i)
print cmd
time.sleep(2)
# 注释掉的
# subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subprocess.call(cmd, shell=True, stdout=open('D:\log\\log.log', 'w'), stderr=subprocess.STDOUT)
time.sleep(30)
driver = webdriver.Remote('http://localhost:' + str(4723 + 2 * i) + '/wd/hub', desired_caps)
hh = Ni(driver)
t = threading.Thread(target=hh.login)
tt.append(t)
class Ni():
def __init__(self, driver):
self.driver = driver
def login(self):
time.sleep(5)
print 111111111
for j in range(3):
# self.cgw = self.driver.find_element_by_id("cn.redcdn.hvs:id/Login_numdemo_edit");
# time.sleep(3)
# self.cgw.click();
# time.sleep(3)
login_Activity.login_phone(self)
# self.bum = self.driver.find_element_by_id("com.tencent.mm:id双击查看原图n")
# self.bum.send_keys('12345678')
# time.sleep(2)
#
# self.gz = self.driver.find_element_by_id("com.tencent.mm:id双击查看原图");
# self.gz.send_keys('jho');
# time.sleep(2)
print 2222222222
# self.driver.keyevent(4)
self.driver.quit()
if __name__ == '__main__':
sever(ip)
time.sleep(2)
for i in tt:
i.start()
阅读全文
0 0
- appium+python一个脚本同时运行在多台android设备
- Docker+Appium实现同时在多台手机上进行Android单元自动化测试
- appium+python 多设备并行执行脚本
- Appium自动化测试-同时运行多个设备
- appium+Python运行脚本环境
- 一台电脑同时运行多个tomcat设备办法
- 用python同时启动多个appium,并让多个手机同时执行脚本
- Python 脚本在后台运行
- appium同时运行两台真机
- linux 下Appium多设备运行
- 在后台运行Python脚本服务
- 在后台运行Python脚本服务
- Python调用adb命令实现对多台设备同时进行reboot
- Perl脚本同时只运行一个实例
- Appium在Android手机执行测试脚本
- 如何在一台linux机器上同时运行多个openvpn客户端
- 避免在一台机器上同时运行同一应用程序的多个实例。
- 在一台机器上同时运行多个Neo4j实例
- Qt菜单、文件、信号与槽最简单程序
- BZOJ2661 / wc2012 连连看【费用流】
- JavaEE课程精讲
- pdf.js 利用HTML5技术显示pdf内容
- java后台报错:Unknown column 'xxx' in 'field list'
- appium+python一个脚本同时运行在多台android设备
- JSON学习小结
- Android源码分析之浅析Android系统启动过程
- ES6——Promise
- 课堂练习2(第四周)
- Java之图片添加文字
- 3.2类的成员函数【C++】
- Sublime Text 最新注册码
- makefile模式规则