telenium
telenium copied to clipboard
TeleniumTestCase :: remotely (android device) run app :: RemoteDisconnected
Description
Sending an app_quit
request often causes a remote disconnection. This is no surprise. It's simply impossible for the app to send a proper response if it's not running anymore. The way telenium_client.py
is coded right now... I don't know if there's a way to make sure the response is sent before closing the app. So what I'm doing instead is simply catching the error and ignoring it if it stems from an app_quit
request.
PR on the way soon.
Various logs and file contents
main.py, test.py & buildozer.spec
All the same a in tito/telenium#20
PyCharm Console Output
/home/pdallair/anaconda3/envs/telenium/bin/python /snap/pycharm-community/261/plugins/python-ce/helpers/pycharm/_jb_unittest_runner.py --path /home/pdallair/dev/PycharmProjects/Telenium/TestApp/test.py
Testing started at 10:12 p.m. ...
Launching unittests with arguments python -m unittest /home/pdallair/dev/PycharmProjects/Telenium/TestApp/test.py in /home/pdallair/dev/PycharmProjects/Telenium/TestApp
> app_quit: ()
Execute: ['adb', 'push', '/tmp/telenium_env.json', '/sdcard/telenium_env.json']
/tmp/telenium_env.json: 1 file pushed, 0 skipped. 0.6 MB/s (58 bytes in 0.000s)
Execute: ['adb', 'shell', 'am', 'start', '-n', 'org.kivy.testapp/org.kivy.android.PythonActivity', '-a', 'org.kivy.android.PythonActivity']
Starting: Intent { act=org.kivy.android.PythonActivity cmp=org.kivy.testapp/org.kivy.android.PythonActivity }
(None, None)
> ping: ()
> get_token: ()
> select: ('//Label[@text~="Test App"]',)
Error
Traceback (most recent call last):
File "/home/pdallair/dev/PycharmProjects/Telenium/telenium/client.py", line 36, in __call__
return response["result"]
KeyError: 'result'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pdallair/dev/PycharmProjects/Telenium/TestApp/test.py", line 13, in test_startup_screen
self.assertExists("//Label[@text~=\"Test App\"]", timeout=2)
File "/home/pdallair/dev/PycharmProjects/Telenium/telenium/tests.py", line 136, in assertExists
self.assertTrue(self.cli.wait(selector, timeout=timeout))
File "/home/pdallair/dev/PycharmProjects/Telenium/telenium/client.py", line 86, in wait
matches = self.select(selector)
File "/home/pdallair/dev/PycharmProjects/Telenium/telenium/client.py", line 38, in __call__
raise TeleniumHttpException(response["error"]["message"])
telenium.client.TeleniumHttpException: Server error
Ran 1 test in 4.156s
FAILED (errors=2)
Failure
Traceback (most recent call last):
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/http/client.py", line 1371, in getresponse
response.begin()
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/http/client.py", line 319, in begin
version, status, reason = self._read_status()
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/http/client.py", line 288, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/util/retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/packages/six.py", line 769, in reraise
raise value.with_traceback(tb)
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/http/client.py", line 1371, in getresponse
response.begin()
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/http/client.py", line 319, in begin
version, status, reason = self._read_status()
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/http/client.py", line 288, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/unittest/suite.py", line 306, in _tearDownPreviousClass
tearDownClass()
File "/home/pdallair/dev/PycharmProjects/Telenium/telenium/tests.py", line 126, in tearDownClass
cls.stop_process()
File "/home/pdallair/dev/PycharmProjects/Telenium/telenium/tests.py", line 114, in stop_process
cls.cli.app_quit()
File "/home/pdallair/dev/PycharmProjects/Telenium/telenium/client.py", line 31, in __call__
response = requests.post(
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/home/pdallair/anaconda3/envs/telenium/lib/python3.9/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
> app_quit: ()