macaca-ios.js /usr/local/lib/node_modules/macaca-ios/lib/macaca-ios.js 更改为和你的一样的代码.
执行后,两个服务都显示这个http://127.0.0.1:8900/session:POST ,并未有启动 8910
现象仍是一个手机上启动两次应用程序,另外一个手机未启动应用程序
#!/usr/bin/python
#-*- coding: UTF-8 -*-
import time
from macaca import WebDriver
from multiprocessing.pool import Pool
import multiprocessing
desired_caps = {
'platformName': 'iOS',
'platformVersion': '10.2.1',
'bundleId':'xxxxx',
'proxyPort':'8910',
'udid': 'xxxxxxxxxxxxxxxxxxxxx',
}
desired_caps1 = {
'platformName': 'iOS',
'platformVersion': '10.1.0',
'reuse' : '3',
'bundleId':'xxxxxxxxxxxx',
'proxyPort':'8900',
'udid':'xxxxxxxxxxxxxxxxxxxxxxxxx',
}
devices = [desired_caps,desired_caps1]
port_list = [3457,3456]
def setUpClass():
for i in range(2):
p = multiprocessing.Process(target = run_server, args = (devices[i], port_list[i]))
print devices[i]
print port_list[i]
p.start()
def run_server(device, port):
server_url = {
'hostname': '127.0.0.1',
'port': port,
}
driver = WebDriver(device, server_url)
driver.init()
time.sleep(2)
setUpClass()
@utopia @xdf 我用的 PY,多机并行有方法传不同的 proxyPort 吗?
#!/usr/bin/python
#-*- coding: UTF-8 -*-
import unittest
import urllib2
import os
import time
from macaca import WebDriver
from multiprocessing.pool import Pool
desired_caps = {
'platformName': 'iOS',
'platformVersion': '10.2.1',
'bundleId':'xxxxxx',
'udid': 'xxxxxxxxxxxxxxx',
}
server_url = {
'hostname': '127.0.0.1',
'port': 3457
}
desired_caps1 = {
'platformName': 'iOS',
'platformVersion': '10.1.0',
'reuse' : '3',
'bundleId':'xxxxxxxx',
'udid':'xxxxxxxxxxxxxxxxxxxx',
}
server_url1 = {
'hostname': '127.0.0.1',
'port': 3456
}
devices = [desired_caps,desired_caps1]
port_list = [3456,3457]
def setUpClass():
pool = Pool(processes=2)
for i in range(2):
pool.apply_async(run_server, args=(devices[i], port_list[i]))
time.sleep(5)
pool.close()
pool.join()
def run_server(device, port):
server_url = {
'hostname': '127.0.0.1',
'port': port,
}
driver = WebDriver(device, server_url)
driver.init()
setUpClass()
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from macaca import WebDriver
import time
from parameters.conf_server import *
import threading
import requests
from multiprocessing.pool import Pool
from middleware.all_case import *
from parameters.run import *
from parameters.configure import *
from parameters.conf_driver import *
from parameters.conf_client import *
# class macacaServer():
# def __init__(self, devices):
#
# self.devices = devices
# self.count = len(devices)
# self.url = 'http://127.0.0.1:%s/wd/hub/status'
def start_server(devices):
# 进程池
count = len(devices)
pool = Pool(processes=count)
port_list = get_port(count)
for i in range(count):
pool.apply_async(run_server, args=(devices[i], port_list[i]))
time.sleep(3)
#self.run_server(self.devices[i],port_list[i])
pool.close()
pool.join()
def run_server(device, port):
r = RunServer(port)
r.start()
while not is_running(port):
time.sleep(1)
server_url = {
'hostname': server_ip,
'port': port,
}
driver = WebDriver(device, server_url)
driver.init()
DRIVER.set_driver(driver)
DRIVER.set_OS(device.get("platformName"))
run_test(driver)
def run_test(driver):
"""
运行测试
"""
test_run(driver,login_pages)
def is_running(port):
"""Determine whether server is running
:return:True or False
"""
url = 'http://127.0.0.1:%s/wd/hub/status'
url1 = url % port
response = None
try:
response = requests.get(url1, timeout=0.01)
if str(response.status_code).startswith('2'):
return True
return False
except requests.exceptions.ConnectionError:
return False
except requests.exceptions.ReadTimeout:
return False
finally:
if response:
response.close()
class RunServer(threading.Thread):
def __init__(self, port):
threading.Thread.__init__(self)
self.cmd = 'macaca server -p %s --verbose' % port
def run(self):
os.system(self.cmd)
if __name__ == "__main__":
b = InitDevice()
start_server(b.get_device())
#80 楼 @tongshanshanshan 不加入并行执行的代码,只用我写的简单的 Demo 两个手机分别执行没有问题。但是用并行执行的代码,只能一个手机能够启动应用程序。是这样的
#71 楼 @tongshanshanshan 单个手机运行时,同样的代码不同的手机,但是其他测试机在我的项目里运行启动不起来,我的手机怎么启动都可以,什么原因呢. 不加入你的并发执行的代码,两个手机单独还能正常执行
#71 楼 @tongshanshanshan 楼主,两部手机只有一个能启动起来
楼主,我的执行以后发现会先执行给 element.py 二次封装事件中的 driver= DRIVER.driver 先赋值 None,后续不再赋值了,导致调用 driver.element('','') 时报错,能把你的框架思路简单说下嘛,如何在其他文件里面正常调用 driver
问题已解决
brew unlink ios-webkit-debug-proxy
brew install ios-webkit-debug-proxy
11:17:15.783 xcodebuild[3768:28327] Initializing test infrastructure.
11:17:15.969 xcodebuild[3768:28333] Creating the test bundle connection.
11:17:15.970 xcodebuild[3768:28333] Listening for proxy connection request from the test bundle (all platforms)
11:17:15.970 xcodebuild[3768:28333] Resuming the connection.
11:17:15.971 xcodebuild[3768:28333] Test connection requires daemon assistance.
11:17:15.971 xcodebuild[3768:28327] Starting test session with ID <__NSConcreteUUID 0x7f9bb5fb2d50> 5812041C-CD33-48F7-9A43-21AFE2145790
11:17:15.972 xcodebuild[3768:28327] Checking test manager availability..., will wait up to 120s
11:17:15.974 xcodebuild[3768:28344] testmanagerd handled session request.
11:17:15.974 xcodebuild[3768:28327] Waiting for test process to launch.
11:17:18.068 xcodebuild[3768:28327] Test operation failure: Test operation was canceled.
11:17:18.068 xcodebuild[3768:28327] _finishWithError:Error Domain=IDETestOperationsObserverErrorDomain Code=3 "Test operation was canceled." UserInfo={NSLocalizedDescription=Test operation was canceled.} didCancel: 1
#1 楼 @Lihuazhang 需要什么类型的信息
打完断点,都没有经过 run_server 方法,就结束了,也没有报错
楼主,按照你的这种代码,我运行了一个 demo,调用 start_server 会先执行 case,再搜索手机,端口信息
except requests.exceptions.ReadTimeout:
return False
#63 楼 @tongshanshanshan 导入我的 import ReadTimeout ,会提示 ReadTimeout 不存在,是需要导入到 pycharm 什么文件呢
操作事件我都封装到 element 里面了,如果里面想用 driver 是不是 driver = DVIVER.driver 就可以了
except ReadTimeout 这个是需要导入,还是自己创建一个 py 文件
pool = Pool(processes=self.count)
这里的 Pool 是什么?
博主,配置成功以后,执行
macaca run -d 文件.py --verbose
才会在网页上显示执行记录吗?
真机不行,不知道 bundleId