目录
1、appium 出现报错 “could not connect to server are you sure it’s running?”
如果要用appium去定位元素的话,应该需要去选择Automatic Server一栏
2、启动时碰到的坑
- 错误提示:
D:\pycharm\Python\Scripts\python.exe C:/Users/Wheat/PycharmProjects/pythonProject/app_01day_project/demo1_appium入门.py
Traceback (most recent call last):
File "D:\pycharm\Python\lib\site-packages\urllib3\connection.py", line 175, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "D:\pycharm\Python\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection
raise err
File "D:\pycharm\Python\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\pycharm\Python\lib\site-packages\urllib3\connectionpool.py", line 706, in urlopen
chunked=chunked,
File "D:\pycharm\Python\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "D:\pycharm\Python\lib\site-packages\urllib3\connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\http\client.py", line 1262, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\http\client.py", line 1308, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\http\client.py", line 1257, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\http\client.py", line 1028, in _send_output
self.send(msg)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\http\client.py", line 968, in send
self.connect()
File "D:\pycharm\Python\lib\site-packages\urllib3\connection.py", line 205, in connect
conn = self._new_conn()
File "D:\pycharm\Python\lib\site-packages\urllib3\connection.py", line 187, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000168E72F4588>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Wheat/PycharmProjects/pythonProject/app_01day_project/demo1_appium入门.py", line 13, in <module>
driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',desired_capabilities=desired_cap)
File "D:\pycharm\Python\lib\site-packages\appium\webdriver\webdriver.py", line 274, in __init__
AppiumConnection(command_executor, keep_alive=keep_alive), desired_capabilities, browser_profile, proxy
File "D:\pycharm\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
self.start_session(capabilities, browser_profile)
File "D:\pycharm\Python\lib\site-packages\appium\webdriver\webdriver.py", line 364, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, parameters)
File "D:\pycharm\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 422, in execute
response = self.command_executor.execute(driver_command, params)
File "D:\pycharm\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 421, in execute
return self._request(command_info[0], url, body=data)
File "D:\pycharm\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 443, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "D:\pycharm\Python\lib\site-packages\urllib3\request.py", line 79, in request
method, url, fields=fields, headers=headers, **urlopen_kw
File "D:\pycharm\Python\lib\site-packages\urllib3\request.py", line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "D:\pycharm\Python\lib\site-packages\urllib3\poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "D:\pycharm\Python\lib\site-packages\urllib3\connectionpool.py", line 796, in urlopen
**response_kw
File "D:\pycharm\Python\lib\site-packages\urllib3\connectionpool.py", line 796, in urlopen
**response_kw
File "D:\pycharm\Python\lib\site-packages\urllib3\connectionpool.py", line 796, in urlopen
**response_kw
File "D:\pycharm\Python\lib\site-packages\urllib3\connectionpool.py", line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "D:\pycharm\Python\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000168E72F4588>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))
Process finished with exit code 1
- 解决步骤
第一步:
driver = Remote(command_executor='http://127.0.0.1:4723/wd/hub',desired_capabilities=desired_cap)
command_executor的端口号一定要与appium上给你一致;这样就解决一部分的bug了
第二步:
查看一下appium里,哪里运行错误,发现发生了 Android 系统权限错误。然后顺着这个错误,发现启动参数的AppActivity少打了个t,为什么会少打这个t呢!!因为我笔记本键盘的t不好使!!!经常按不下去,我哭了啊!!!
教读 Appium 日志的文章:https://blog.youkuaiyun.com/weixin_46635091
错误提示:error running command: Error: activity and pkg are required to start an application
3、aapt dump badging 软件.apk ,提示aapt不是内部命令解决方式
系统变量的path,把相对路径改为绝对路径即可