openatx / facebook-wda Goto Github PK
View Code? Open in Web Editor NEWFacebook WebDriverAgent Python Client Library (not official)
License: MIT License
Facebook WebDriverAgent Python Client Library (not official)
License: MIT License
Hi,
I found that when I use wda_session.tap(x, y) method on my iPad, there is a 50% difference.
For example, if I want to tap (100, 200) on my iPad screen, I have to use wda_session.tap(50, 100).
I have to add a new function to my code like this:
def click(wda_session, x, y):
'''
wda has a bug
'''
wda_session.tap(x//2, y//2)
Line 404 in aa64420
需求是这样的:多线程运行了多台设备,如何给不同的设备设置不同的 alert_callback
iOS9可以通过bundle打开应用、iOS11不行、请问是什么原因
啥时候支持 hybrid app呢
Hi,
Can we add also additional argument in the session, so we might to open Safari app with selected url?
s = client.session("localhost:8100","-u https://www.google.com/ncr")
As we know the arguments should be pass as list, but we can split this inside your code.
curl -X POST $JSON_HEADER \ -d "{\"desiredCapabilities\":{\"bundleId\":\"com.apple.mobilesafari\", \"arguments\":[\"-u\", \"https://www.google.com/ncr\"]}}" \ $DEVICE_URL/session
I want to do continuous swipe as faster as it can do, but how?
I don't find any solutions in Readme,Please help!
我只运行了你的代码示例:
import wda
c = wda.Client('http://localhost:8100')
就报出了如下错误,不清楚是哪里出了问题
`retry to connect, error: HTTPConnectionPool(host='localhost', port=8100): Max retries exceeded with url: /status (Caused by Ne
wConnectionError('<urllib3.connection.HTTPConnection object at 0x108572908>: Failed to establish a new connection: [Errno 8] n
odename nor servname provided, or not known',))
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 745, in getadd
rinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in
request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in
_send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, inendheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in_send_output
self.send(msg)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x108572908>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8100): Max retries exceeded with url: /status (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x108572908>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 70, in httpdo
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8100): Max retries exceeded with url: /status (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x108572908>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, inrequest
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in_send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, inendheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in_send_output
self.send(msg)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10858c080>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known`
Hi,
I'm using your module and I recognized, that your module did not have implemented change_orientation functionality.
From what I see on page:
https://github.com/facebook/WebDriverAgent/wiki/Queries
we have possibility to change screen orientation.
Can we/you add this functionality to your module?
Traceback (most recent call last):
File "/Users/fengxiaooyong/Documents/百度工作/脚本管理/otatest/iosota.py", line 14, in
s = c.session(bundle_id)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 304, in session
res = self.http.post('session', data)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 109, in fetch
return self._fetch_no_alert(method, url, data)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 115, in _fetch_no_alert
return httpdo(target_url, method, data)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 77, in httpdo
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
手机是iphone 6 plus 版本是12.3.1,Xcode是10.2.1,facebook-wda 0.2.3
在模拟器上运行没有问题,但是真机上运行就有问题
iproxy 8100 8100 使用的是这个代理 ,请教下大神们
为什么通过XPATH 方式定位速度时,速度这么慢?
I got module 'wda' has no attribute 'Client' error when using python3.6
s = wda.Client().session()
wda.DEBUG = False
s=wda.Client('http://10.141.18.145:8100')
s(label='My Account').exists
Traceback (most recent call last):
File "", line 1, in
TypeError: 'Client' object is not callable
Here is the page source. I have a page where I want to click on the button of a particular text For e.g I want to click on the button next to the text Jhon. But both the text Jhon and Lisa has the same button id.
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Jhon " name="Jhon " label="Jhon " enabled="true" visible="true" x="70" y="73" width="241" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="companion checkbox checked" label="companion checkbox checked" enabled="true" visible="true" x="329" y="79" width="29" height="28"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Lisa " name="Lisa " label="Lisa " enabled="true" visible="true" x="70" y="73" width="241" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="companion checkbox checked" label="companion checkbox checked" enabled="true" visible="true" x="329" y="79" width="29" height="28"/>
例如一个页面有多个Cell或Button/StaticText等属性元素,假设用s(className="Cell")进行定位。
用exists属性检查元素是否存在,s(className="Cell")[0].exists正常返回True,而s(className="Cell")[1].exists返回False,1以上目前都返回False
使用s(className='Cell', index=0).exists返回true
使用s(className='Cell', index=1).exists返回false
但是使用s(className='Cell', index=1).find_elements()能获取到15个元素
class Session 的 __call__
方法中会将 className 参数改为 class_name。class Selector __init__
方法中当 class_name 参数不为空时会输出
Warning: prefer use className instead of class_name
结果就是只要用到 className 的时候不管用 className
还是 class_name
都会打印这条 Warning
error:
GenericDict(value='Error Domain=com.facebook.WebDriverAgent Code=1 "Timeout waiting until SpringBoard is visible" UserInfo={NSLocalizedDescription=Timeout waiting until SpringBoard is visible}', sessionId='2337B533-0195-492A-BF51-411C70F69B91', status=13)
First very thanks this great work, i use this to control my ios device. now i must make a function like :
my question is:
1.session.width & height is 1024 * 768
2.screenshot.width & height is 2048 * 1536
these two size is different so when i get template size, it not right at screen.( i guess session.tap is work with session.size. right?)
can you tell me how to make screenshot png with session.size or how to make tap method work with screenshot png axis ?
thanks!
例如一个页面有多个Cell或Button/StaticText等属性元素,假设用d(className="Cell")进行定位。
用exists属性检查元素是否存在,d(className="Cell")[0].exists正常返回True,而d(className="Cell")[1].exists返回False,1以上目前都返回False
Line 501 in 8dd4577
when I clicked an input element, how to find it so i can use e.settext() afterwards?
If we will will want to get objects with ' or " character we observe WDAError(status 13):
session(text="don't")
I think in line 600:
https://github.com/openatx/facebook-wda/blob/master/wda/__init__.py
It should be added some method which will add "" before ' or " to avoid of having issue with parsing when chain is created(line:672), as we might to catch situation:
"name == 'I don't want'"
which is causing mentioned by me error.
Tested on WebDriverAgent - a10768631110f4b7c2d7ca328a9f11186464ae35
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 197, in start_auto_operation
self.app_record_screen(self.click_file_path, self.config_path)
File "main.py", line 145, in app_record_screen
runner.run()
File "/Users/tian/Documents/test/app_runner.py", line 416, in run
self.after_run()
File "/Users/tian/Documents/test/app_runner.py", line 74, in after_run
super(appRunner, self).after_run()
File "/Users/tian/Documents/test/app_runner.py", line 429, in after_run
self.close_app()
File "/Users/tian/Documents/test/app_runner.py", line 136, in close_app
self.session.close()
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 473, in close
return self.http.delete('/')
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 101, in fetch
return self._fetch_no_alert(method, url, data)
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 107, in _fetch_no_alert
return httpdo(target_url, method, data)
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 75, in httpdo
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
INFO: 2018-06-13 12:08:19, filename:main.py, lineno:212, thread:140735604671360
/Users/tian/Documents/ios-blackbox/blackdata/app/video/头条_6.7.5_iPhone7P_WiFi_首页视频1.mov
ERROR: 2018-06-13 12:08:19, filename:main.py, lineno:297, thread:140735604671360
MainRunner config files occur an error,error message = Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 290, in traverse_config
runner.start_auto_operation()
File "main.py", line 197, in start_auto_operation
self.app_record_screen(self.click_file_path, self.config_path)
File "main.py", line 145, in app_record_screen
runner.run()
File "/Users/tian/Documents/test/app_runner.py", line 416, in run
self.after_run()
File "/Users/tian/Documents/test/app_runner.py", line 74, in after_run
super(appRunner, self).after_run()
File "/Users/tian/Documents/test/app_runner.py", line 429, in after_run
self.close_app()
File "/Users/tian/Documents/test/app_runner.py", line 136, in close_app
self.session.close()
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 473, in close
return self.http.delete('/')
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 101, in fetch
return self._fetch_no_alert(method, url, data)
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 107, in _fetch_no_alert
return httpdo(target_url, method, data)
File "/usr/local/lib/python3.6/site-packages/wda/init.py", line 75, in httpdo
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
经常在测试了一会之后,就出现这个错误。不知道是什么原因。
春节前WebDriverAgent参照WD spec调整了接口url地址。直到最近,旧的接口url地址被废弃了 facebookarchive/WebDriverAgent@dccf5c8
此工程需要对应的修改
before | after | status |
---|---|---|
POST /homescreen | POST /wda/homescreen | done |
POST /deactivateApp | POST /wda/deactivateApp | done |
POST /source | GET /source | done |
GET /window/:uuid/size | GET /window/size | done |
POST /element/:uuid/pinch | POST /wda/element/:uuid/pinch | done |
GET /element/:uuid/accessible | GET /wda/element/:uuid/accessible | done |
GET /element/:uuid/accessibilityContainer | GET /wda/element/:uuid/accessibilityContainer | |
POST /uiaElement/:uuid/doubleTap | POST /wda/element/:uuid/doubleTap | done |
POST /uiaElement/:uuid/twoFingerTap | POST /wda/element/:uuid/twoFingerTap | |
POST /uiaElement/:uuid/touchAndHold | POST /wda/element/:uuid/touchAndHold | done |
POST /uiaElement/:uuid/scroll | POST /wda/element/:uuid/scroll | |
POST /uiaTarget/:uuid/dragfromtoforduration | POST /wda/element/:uuid/dragfromtoforduration | not implemented |
POST /tap/:uuid | POST /wda/tap/:uuid | done |
POST /touchAndHold | POST /wda/touchAndHold | done |
POST /doubleTap | POST /wda/doubleTap | done |
POST /keys | POST /wda/keys | done |
GET /uiaElement/:uuid/getVisibleCells | GET /wda/element/:uuid/getVisibleCells | |
GET /healthcheck | GET /wda/healthcheck | done |
POST /simulator/touch_id | POST /wda/touch_id |
test_b.py retry to connect, error: HTTPConnectionPool(host='localhost', port=8100): Read timed out. (read timeout=60.0)
s.alert.accept()
test_b.py:31:
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/wda/init.py:508: in accept
return self.http.post('/alert/accept')
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/wda/init.py:101: in fetch
return self._fetch_no_alert(method, url, data)
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/wda/init.py:107: in _fetch_no_alert
return httpdo(target_url, method, data)
url = 'http://localhost:8100/session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/alert/accept'
method = 'post', data = None
def httpdo(url, method='GET', data=None):
"""
Do HTTP Request
"""
start = time.time()
if isinstance(data, dict):
data = json.dumps(data)
if DEBUG:
print("Shell: curl -X {method} -d '{data}' '{url}'".format(method=method.upper(), data=data or '', url=url))
try:
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout) as e:
# retry again
print('retry to connect, error: {}'.format(e))
time.sleep(1.0)
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
retjson = response.json()
if DEBUG:
ms = (time.time() - start) * 1000
print('Return ({:.0f}ms): {}'.format(ms, json.dumps(retjson, indent=4)))
r = convert(retjson)
if r.status != 0:
raise WDAError(r.status, r.value)
E wda.WDAError: WDAError(status=27, value={})
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/wda/init.py:83: WDAError
------------------------------ Captured log call -------------------------------
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/elements HTTP/1.1" 200 162
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/wda/tap/0 HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/wda/tap/0 HTTP/1.1" 200 94
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 214 INFO Starting new HTTP connection (1): localhost
connectionpool.py 401 DEBUG "POST /session/BBBAA7CE-6EDB-4D3D-B1B9-CF09A4AADC29/alert/accept HTTP/1.1" 200 95
=============================== warnings summary ===============================
None
passing a string to pytest.main() is deprecated, pass a list of arguments instead.
-- Docs: http://doc.pytest.org/en/latest/warnings.html
=============== 1 failed, 1 passed, 1 warnings in 93.43 seconds ================
Process finished with exit code 0
机型:iPhone 7
系统版本:11.2.1
显示宽度:375
显示高度:667
(横屏相反)
在横屏状态下LANDSCAPE_RIGHT
,LANDSCAPE
,当i
值出现大于等于750时,就会出现点击错位的问题
import wda
client = wda.Client()
session = client.session()
session.orientation = wda.LANDSCAPE
def tap(x, y):
session.tap_hold(x / 2, y / 2, 0.1)
def main():
for v in range(100, 500, 100):
for i in range(100, 1300, 100):
tap(v, i)
# 当`i`值出现大于等于750时,就会出现点击错位的问题
if __name__ == "__main__":
main()
我尝试在备忘录中重现Bug状态,请参考以下截图
Traceback (most recent call last):
File "atxOTA.py", line 20, in
s = c.session('com.apple.mobilesafari', ['-u', 'https://www.google.com/ncr'])
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 302, in session
res = self.http.post('session', data)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 107, in fetch
return self._fetch_no_alert(method, url, data)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 113, in _fetch_no_alert
return httpdo(target_url, method, data)
File "/Users/fengxiaooyong/Library/Python/2.7/lib/python/site-packages/wda/init.py", line 89, in httpdo
raise WDAError(r.status, r.value)
wda.WDAError: WDAError(status=13, value='bundleId' desired capability not provided)
我看了webdriver的接口,发现我们传过去的是个json,接口收不到
def httpdo(url, method='GET', data=None):
"""
Do HTTP Request
"""
start = time.time()
if DEBUG:
body = json.dumps(data)
print("Shell: curl -X {method} -d '{body}' '{url}'".format(method=method.upper(), body=body or '', url=url))
try:
print(data)
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):
# retry again
# print('retry to connect, error: {}'.format(e))
time.sleep(1.0)
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
if DEBUG:
ms = (time.time() - start) * 1000
print('Return ({:.0f}ms): {}'.format(ms, response.text))
response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)
里面的json参数,改成data就可以正常的工作了
python -m atx gui -s http://192.168.199.146:8100
2019-06-16 00:03:06.259 DEBUG [tkgui: 412] gui starting(scale: 0.5) ...
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/site-packages/atx/main.py", line 199, in
main()
File "/usr/local/lib/python2.7/site-packages/atx/main.py", line 195, in main
args.func(args)
File "/usr/local/lib/python2.7/site-packages/atx/main.py", line 49, in _inner
return inject(mod.main, pargs)
File "/usr/local/lib/python2.7/site-packages/atx/main.py", line 40, in inject
return func(*args)
File "/usr/local/lib/python2.7/site-packages/atx/cmds/tkgui.py", line 425, in main
gui = CropIDE('ATX GUI SN: %s' % serial, ratio=scale, device=d)
File "/usr/local/lib/python2.7/site-packages/atx/cmds/tkgui.py", line 98, in init
self._init_vars()
File "/usr/local/lib/python2.7/site-packages/atx/cmds/tkgui.py", line 159, in _init_vars
self.draw_image(self._device.screenshot())
File "/usr/local/lib/python2.7/site-packages/atx/drivers/mixin.py", line 62, in _inner
_retval = fn(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/atx/drivers/mixin.py", line 404, in screenshot
screen = self._take_screenshot()
File "/usr/local/lib/python2.7/site-packages/atx/drivers/ios_webdriveragent.py", line 174, in _take_screenshot
img = Image.open(BytesIO(raw_png))
TypeError: 'PngImageFile' does not have the buffer interface
iOS 12 XR
In XCUIELement+FBIsVisible.m,
Collapsed in this line:XCElementSnapshot *hitElement = [self hitTest:midPoint];
What should I do?
我在试你给的ReadMe,隐藏键盘报这个错
Traceback (most recent call last):
File "ba.py", line 47, in
s.keyboard_dismiss()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wda/init.py", line 465, in keyboard_dismiss
raise RuntimeError("not pass tests, this method is not allowed to use")
RuntimeError: not pass tests, this method is not allowed to use
swipe速度好慢,调了第5个参数也还是没用,有源码哪里可以改的粗暴一点啊
import wda
c = wda.Client()
c.screenshot()
出现:
WebDriverAgentRunner-Runner[6458:1441982] +[XCAXClient_iOS sharedClient]: unrecognized selector sent to class 0x102d43e50
c = wda.Client(‘http://localhost:8100')
这个地方,设置了不同的端口(8103、8106),log里面看到
WebDriverAgentRunner-Runner[30959:8510846] ServerURLHere->http://169.254.33.58:8100<-ServerURLHere
请问这个地方的8100,是写死的么 😿
This issue is specific to version 0.2.1, and doesnt appear in version 0.1.2
My code selects an element from the session, then uses one of the element methods on it:
wda.DEBUG=True
passwordField = self.session(className="SecureTextField")
passwordField.set_text(self.TEST_INPUT_DATA['PASSWORD'])
Yet, this element method throws an error because of a certain **
string that gets prepended to the value:
CHAIN: **/XCUIElementTypeSecureTextField
Shell: curl -X POST -d '{"using": "class chain", "value": "**/XCUIElementTypeSecureTextField"}' 'http://127.0.0.1:8100/session/0C84F47E-06E6-43BF-AFB9-E0C882FB5112/elements'
Return (58ms): {
"status": 13,
"sessionId": "0C84F47E-06E6-43BF-AFB9-E0C882FB5112",
"value": "Cannot parse class chain query '**/XCUIElementTypeSecureTextField'. Unexpected character detected at position 2:\n**
Lines 299 to 303 in 2412383
看了下代码后面 httpdo
应该是传给了 request
这样的话应该不需要 json.dumps
吧。
本地环境把这个 dumps
删掉之后可以创建 session 了,否则一只报错连接不上。
RT,是有什么别的考虑吗?感觉属性更好用
RT
timeout=20的时候,我的set_text到httpdo的时候报:
ReadTimeout: HTTPConnectionPool(host='localhost', port=5000): Read timed out. (read timeout=20)
我手动修改成50就可以了,这个能提供成吗:
def httpdo(url, method='GET', data=None,timeout=20):
response = fn(url, data=data, timeout=timeout)
set_text也要对应修改
admindeMacBook-Pro:~ admin$ pip install --pre facebook-wda
Collecting facebook-wda
Using cached facebook_wda-0.2.2.dev1-py2-none-any.whl
Requirement already satisfied: six in ./Library/Python/2.7/lib/python/site-packages (from facebook-wda)
Collecting requests>=2.9.1 (from facebook-wda)
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests>=2.9.1->facebook-wda)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests>=2.9.1->facebook-wda)
Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.9.1->facebook-wda)
Using cached certifi-2017.11.5-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.9.1->facebook-wda)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Installing collected packages: idna, urllib3, certifi, chardet, requests, facebook-wda
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip/utils/init.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/idna'
你好,看到XCUICoordinate中func press(forDuration duration: TimeInterval)参数是有时间的,这边没找到长按home键的方法,是否或者可以支持长按home键吗?
报如下的错误 : requests.exceptions.ReadTimeout: HTTPConnectionPool(host='localhost', port=8100): Read timed out. (read timeout=60.0)
而且我发现当通过py脚本打印页面数据结构的报错的时候。 我重新Product -> Test 重新启动WebDriverAgentRunner, 然后Safari
通过网页 localhost:8100/inspector ( 我已经通过 tcprelay.py -t 8100:8100 端口转发了 ), 也是发现页面进不去的 , 好像也是得不到页面的数据结构, 导致页面进不去似的
但是我发现我把手机网络断掉 , 上面的1,2 我阐述的问题 都解决了, print driver.source() 能够打印数据结构, 也能Safari 通过网页 localhost:8100/inspector 进去看到页面, 但是我手机开网络, 1,2 问题又会重现, 这是什么原因导致的呢? 希望大佬解惑下 感谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.