环境:appium 1.15.1 、 pycharm
步骤:pycharm运行脚本报错
脚本:
from time import sleep
import pytest
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
class TestDw:
def setup(self):
desre_cap = {
"deviceName": "emulator-5554",
"automationName": "appium",
"platformName": "Android",
"platformVersion": "6.0.1",
"appPackage": "com.xueqiu.android",
"appActivity": ".view.WelcomeActivityAlias",
"noReset": True,
}
self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desre_cap)
self.driver.implicitly_wait(5)
def teardown(self):
self.driver.quit()
def test_search(self):
'''
1.打开雪球首页
2.定位搜索框
3.判断搜索框是否可用并查看搜索框name属性值
4.打印搜索框元素坐标和宽高
5.输入阿里巴巴,判断阿里巴巴是否可见
6.如果可见打印搜索成功如果不可见答应搜索失败
'''
sleep(10)
el2 = self.driver.find_element_by_id("com.xueqiu.android:id/home_search")
serch = el2.is_enabled()
print(serch)
print(el2.location)
print(el2.size)
if serch == True:
el2.click()
el3 = self.driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
el3.send_keys("albb")
el4 = self.driver.find_element_by_xpath("//*[@resource-id='com.xueqiu.android:id/name' and @text='阿里巴巴']")
dis = el4.get_attribute("displayed")
if dis == "true":
el4.click()
sleep(5)
cuurent = float(self.driver.find_element_by_id("com.xueqiu.android:id/current_price").text)
assert cuurent > 200
if __name__ == '__main__':
pytest.main()
pycharm报错信息:
platform darwin -- Python 3.7.2rc1, pytest-5.4.2, py-1.8.1, pluggy-0.13.1 -- /Users/v_liuzhen01/PycharmProjects/webxiangmu/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/v_liuzhen01/PycharmProjects/webxiangmu
collected 3 items
test_dw.py::TestDw::test_search ERROR
test_dw.py::TestDw::test_touchaction SKIPPED
test_dw.py::TestDw::test_automator SKIPPED
========================================================================= ERRORS ==========================================================================
__________________________________________________________ ERROR at setup of TestDw.test_search ___________________________________________________________
self = <test_dw.TestDw object at 0x10290bd68>
def setup(self):
desre_cap = {
"deviceName": "emulator-5554",
"automationName": "appium",
"platformName": "Android",
"platformVersion": "6.0.1",
"appPackage": "com.xueqiu.android",
"appActivity": ".view.WelcomeActivityAlias",
"noReset": True,
}
self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desre_cap)
> self.driver.implicitly_wait(5)
test_dw.py:22:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:912: in implicitly_wait
'implicit': int(float(time_to_wait) * 1000)})
venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:321: in execute
self.error_handler.check_response(response)
venv/lib/python3.7/site-packages/appium/webdriver/errorhandler.py:29: in check_response
raise wde
venv/lib/python3.7/site-packages/appium/webdriver/errorhandler.py:24: in check_response
super(MobileErrorHandler, self).check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <appium.webdriver.errorhandler.MobileErrorHandler object at 0x10292ef98>
response = {'status': 404, 'value': '{"value":{"error":"invalid session id","message":"A session is either terminated or not star...ules/appium/node_modules/_raw-body@2.4.0@raw-body/index.js:273:7)\\n at IncomingMessage.emit (events.js:205:15)"}}'}
def check_response(self, response):
"""
Checks that a JSON response from the WebDriver does not have an error.
:Args:
- response - The JSON response from the WebDriver server as a dictionary
object.
:Raises: If the response contains an error message.
"""
status = response.get('status', None)
if status is None or status == ErrorCode.SUCCESS:
return
value = None
message = response.get("message", "")
screen = response.get("screen", "")
stacktrace = None
if isinstance(status, int):
value_json = response.get('value', None)
if value_json and isinstance(value_json, basestring):
import json
try:
value = json.loads(value_json)
if len(value.keys()) == 1:
value = value['value']
status = value.get('error', None)
if status is None:
status = value["status"]
message = value["value"]
if not isinstance(message, basestring):
value = message
message = message.get('message')
else:
message = value.get('message', None)
except ValueError:
pass
exception_class = ErrorInResponseException
if status in ErrorCode.NO_SUCH_ELEMENT:
exception_class = NoSuchElementException
elif status in ErrorCode.NO_SUCH_FRAME:
exception_class = NoSuchFrameException
elif status in ErrorCode.NO_SUCH_WINDOW:
exception_class = NoSuchWindowException
elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
exception_class = StaleElementReferenceException
elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
exception_class = ElementNotVisibleException
elif status in ErrorCode.INVALID_ELEMENT_STATE:
exception_class = InvalidElementStateException
elif status in ErrorCode.INVALID_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
exception_class = InvalidSelectorException
elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
exception_class = ElementNotSelectableException
elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
exception_class = ElementNotInteractableException
elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
exception_class = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
elif status in ErrorCode.TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.SCRIPT_TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.UNKNOWN_ERROR:
exception_class = WebDriverException
elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
exception_class = UnexpectedAlertPresentException
elif status in ErrorCode.NO_ALERT_OPEN:
exception_class = NoAlertPresentException
elif status in ErrorCode.IME_NOT_AVAILABLE:
exception_class = ImeNotAvailableException
elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
exception_class = ImeActivationFailedException
elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
exception_class = MoveTargetOutOfBoundsException
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
else:
exception_class = WebDriverException
if value == '' or value is None:
value = response['value']
if isinstance(value, basestring):
if exception_class == ErrorInResponseException:
raise exception_class(response, value)
raise exception_class(value)
if message == "" and 'message' in value:
message = value['message']
screen = None
if 'screen' in value:
screen = value['screen']
stacktrace = None
if 'stackTrace' in value and value['stackTrace']:
stacktrace = []
try:
for frame in value['stackTrace']:
line = self._value_or_default(frame, 'lineNumber', '')
file = self._value_or_default(frame, 'fileName', '<anonymous>')
if line:
file = "%s:%s" % (file, line)
meth = self._value_or_default(frame, 'methodName', '<anonymous>')
if 'className' in frame:
meth = "%s.%s" % (frame['className'], meth)
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == ErrorInResponseException:
raise exception_class(response, message)
elif exception_class == UnexpectedAlertPresentException:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.InvalidSessionIdException: Message: A session is either terminated or not started
venv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py:242: InvalidSessionIdException
================================================================= short test summary info =================================================================
ERROR test_dw.py::TestDw::test_search - selenium.common.exceptions.InvalidSessionIdException: Message: A session is either terminated or not started
appium Server信息:
[Appium] Welcome to Appium v1.15.1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"appium:deviceName":"emulator-5554","appium:automationName":"appium","platformName":"Android","appium:platformVersion":"6.0.1","appium:appPackage":"com.xueqiu.android","appium:appActivity":".view.WelcomeActivityAlias","appium:noReset":true,"appium:skipDeviceInitialization":true}]},"desiredCapabilities":{"deviceName":"emulator-5554","automationName":"appium","platformName":"Android","platformVersion":"6.0.1","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"deviceName":"emulator-5554","automationName":"appium","platformName":"Android","platformVersion":"6.0.1","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true},null,{"firstMatch":[{"appium:deviceName":"emulator-5554","appium:automationName":"appium","platformName":"Android","appium:platformVersion":"6.0.1","appium:appPackage":"com.xueqiu.android","appium:appActivity":".view.WelcomeActivityAlias","appium:noReset":true,"appium:skipDeviceInitialization":true}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1589811103621 (22:11:43 GMT+0800 (中国标准时间))
[Appium]
[Appium] ======================================================================
[Appium] DEPRECATION WARNING:
[Appium]
[Appium] The 'automationName' capability was not provided in the desired
[Appium] capabilities for this Android session
[Appium]
[Appium] Setting 'automationName=UiAutomator2' by default and using the
[Appium] UiAutomator2 Driver
[Appium]
[Appium] The next major version of Appium (2.x) will **require** the
[Appium] 'automationName' capability to be set for all sessions on all
[Appium] platforms
[Appium]
[Appium] In previous versions (Appium <= 1.13.x), the default was
[Appium] 'automationName=UiAutomator1'
[Appium]
[Appium] If you wish to use that automation instead of UiAutomator2, please
[Appium] add 'automationName=UiAutomator1' to your desired capabilities
[Appium]
[Appium] For more information about drivers, please visit
[Appium] http://appium.io/docs/en/about-appium/intro/ and explore the
[Appium] 'Drivers' menu
[Appium]
[Appium] ======================================================================
[Appium]
[Appium] Appium v1.15.1 creating new AndroidUiautomator2Driver (v1.54.1) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver] "alwaysMatch": {
[debug] [BaseDriver] "platformName": "Android",
[debug] [BaseDriver] "appium:deviceName": "emulator-5554",
[debug] [BaseDriver] "appium:automationName": "appium",
[debug] [BaseDriver] "appium:platformVersion": "6.0.1",
[debug] [BaseDriver] "appium:appPackage": "com.xueqiu.android",
[debug] [BaseDriver] "appium:appActivity": ".view.WelcomeActivityAlias",
[debug] [BaseDriver] "appium:noReset": true,
[debug] [BaseDriver] "appium:skipDeviceInitialization": true
[debug] [BaseDriver] },
[debug] [BaseDriver] "firstMatch": [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 3988d8fb-ec0a-4b11-b2aa-4fa5e2be8fa0
[UiAutomator2] Starting 'com.xueqiu.android' directly on the device
[ADB] Found 2 'build-tools' folders under '/Applications/android-sdk-macosx' (newest first):
[ADB] /Applications/android-sdk-macosx/build-tools/29.0.2
[ADB] /Applications/android-sdk-macosx/build-tools/28.0.3
[ADB] Using 'adb' from '/Applications/android-sdk-macosx/platform-tools/adb'
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] Connected devices: [{"udid":"emulator-5554","state":"device"}]
[AndroidDriver] Looking for a device with Android '6.0.1'
[debug] [ADB] Setting device id to emulator-5554
[ADB] Getting device platform version
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release'
[debug] [ADB] Current device property 'ro.build.version.release': 6.0
[debug] [ADB] Setting device id to emulator-5554
[AndroidDriver] Using device: emulator-5554
[ADB] Using 'adb' from '/Applications/android-sdk-macosx/platform-tools/adb'
[debug] [ADB] Setting device id to emulator-5554
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 23
[debug] [ADB] Device API level: 23
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] 'skipDeviceInitialization' is set. Skipping device initialization.
[debug] [Logcat] Starting logcat capture
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8202
[debug] [ADB] Forwarding system: 8202 to device: 6790
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward tcp\:8202 tcp\:6790'
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server'
[debug] [ADB] 'io.appium.uiautomator2.server' is installed
[debug] [ADB] Getting package info for 'io.appium.uiautomator2.server'
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server'
[debug] [ADB] The version name of the installed 'io.appium.uiautomator2.server' is greater or equal to the application version name ('4.8.2' >= '4.8.2')
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[debug] [ADB] Checking app cert for /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.8.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.8.2.apk
[ADB] Using 'apksigner.jar' from '/Applications/android-sdk-macosx/build-tools/29.0.2/lib/apksigner.jar'
[debug] [ADB] Starting apksigner: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin/java -Xmx1024M -Xss1m -jar /Applications/android-sdk-macosx/build-tools/29.0.2/lib/apksigner.jar verify --print-certs /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server\@4.8.2\@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.8.2.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB]
[debug] [ADB] '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.8.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.8.2.apk' is signed with the default certificate
[debug] [ADB] Getting install status for io.appium.uiautomator2.server.test
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server.test'
[debug] [ADB] 'io.appium.uiautomator2.server.test' is installed
[debug] [ADB] Checking app cert for /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.8.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] Starting apksigner: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin/java -Xmx1024M -Xss1m -jar /Applications/android-sdk-macosx/build-tools/29.0.2/lib/apksigner.jar verify --print-certs /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server\@4.8.2\@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB]
[debug] [ADB] '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.8.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk' is signed with the default certificate
[UiAutomator2] Server packages are not going to be (re)installed
[debug] [UiAutomator2] Waiting up to 30000ms for services to be available
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell pm list instrumentation'
[debug] [UiAutomator2] Instrumentation target 'io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner' is available
[debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [UiAutomator2] Performing shallow cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected (socket hang up)
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] Starting UIAutomator2 server 4.8.2
[UiAutomator2] Using UIAutomator2 server from '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.8.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.8.2.apk' and test from '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.8.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk'
[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","emulator-5554","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[debug] [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8202/wd/hub/status] with no body
[WD Proxy] socket hang up
[debug] [WD Proxy] Error: socket hang up
[debug] [WD Proxy] at connResetException (internal/errors.js:559:14)
[debug] [WD Proxy] at Socket.socketOnEnd (_http_client.js:436:23)
[debug] [WD Proxy] at Socket.emit (events.js:205:15)
[debug] [WD Proxy] at endReadableNT (_stream_readable.js:1154:12)
[debug] [WD Proxy] at processTicksAndRejections (internal/process/task_queues.js:84:9)
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8202/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
[debug] [UiAutomator2] The initialization of the instrumentation process took 2045ms
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8202/wd/hub/session] with body: {"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"emulator-5554","automationName":"appium","platformVersion":"6.0.1","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true},"platformName":"Android","deviceName":"emulator-5554","automationName":"appium","platformVersion":"6.0.1","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true,"deviceUDID":"emulator-5554"}],"alwaysMatch":{}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"d5394f06-2ad1-4be9-9b15-996a11587f85","value":{"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"emulator-5554","automationName":"appium","platformVersion":"6.0.1","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true},"platformName":"Android","deviceName":"emulator-5554","automationName":"appium","platformVersion":"6.0.1","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true,"deviceUDID":"emulator-5554"}],"alwaysMatch":{}},"sessionId":"d5394f06-2ad1-4be9-9b15-996a11587f85"}}
[WD Proxy] Determined the downstream protocol as 'W3C'
[debug] [WD Proxy] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8202/wd/hub/session/d5394f06-2ad1-4be9-9b15-996a11587f85/appium/device/info] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"d5394f06-2ad1-4be9-9b15-996a11587f85","value":{"androidId":"83e3c207901d37c8","apiVersion":"23","bluetooth":null,"brand":"Android","carrierName":"Android","displayDensity":420,"locale":"zh_CN","manufacturer":"unknown","model":"Android SDK built for x86","networks":[{"capabilities":{"SSID":null,"linkDownBandwidthKbps":102400,"linkUpstreamBandwidthKbps":51200,"networkCapabilities":"NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_CBS,NET_CAPABILITY_FOTA,NET_CAPABILITY_IMS,NET_CAPABILITY_SUPL,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_MMS,NET_CAPABILITY_INTERNET,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_IA","signalStrength":null,"transportTypes":"TRANSPORT_CELLULAR"},"detailedState":"CONNECTED","extraInfo":"epc.tmobile.com","isAvailable":true,"isConnected":true,"isFailover":false,"isRoaming":false,"state":"CONNECTED","subtype":13,"subtypeName":"LTE","type":0,"typeName":"MOBILE"}],"platformVersion":"6.0","realDisplaySize":"1080x1920","timeZone":"Asia/Shanghai"}}
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'com.xueqiu.android/.view.WelcomeActivityAlias and waiting for 'com.xueqiu.android/.view.WelcomeActivityAlias'
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
[debug] [WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8202/wd/hub/session/d5394f06-2ad1-4be9-9b15-996a11587f85/appium/device/pixel_ratio] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"d5394f06-2ad1-4be9-9b15-996a11587f85","value":2.625}
[debug] [WD Proxy] Matched '/appium/device/system_bars' to command name 'getSystemBars'
[debug] [WD Proxy] Proxying [GET /appium/device/system_bars] to [GET http://127.0.0.1:8202/wd/hub/session/d5394f06-2ad1-4be9-9b15-996a11587f85/appium/device/system_bars] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"d5394f06-2ad1-4be9-9b15-996a11587f85","value":{"statusBar":63}}
[debug] [WD Proxy] Matched '/window/current/size' to command name 'getWindowSize'
[debug] [WD Proxy] Proxying [GET /window/current/size] to [GET http://127.0.0.1:8202/wd/hub/session/d5394f06-2ad1-4be9-9b15-996a11587f85/window/current/size] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"d5394f06-2ad1-4be9-9b15-996a11587f85","value":{"height":1794,"width":1080}}
[Appium] New AndroidUiautomator2Driver session created successfully, session 3988d8fb-ec0a-4b11-b2aa-4fa5e2be8fa0 added to master session list
[Appium] Closing session, cause was 'Unexpected shutdown'
[Appium] Removing session 3988d8fb-ec0a-4b11-b2aa-4fa5e2be8fa0 from our master session list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1589811110187 (22:11:50 GMT+0800 (中国标准时间))
[debug] [W3C (3988d8fb)] Cached the protocol value 'W3C' for the new session 3988d8fb-ec0a-4b11-b2aa-4fa5e2be8fa0
[debug] [W3C (3988d8fb)] Responding to client with driver.createSession() result: {"capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"emulator-5554","automationName":"appium","platformVersion":"6.0.1","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true},"platformName":"Android","deviceName":"emulator-5554","automationName":"appium","platformVersion":"6.0","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","noReset":true,"skipDeviceInitialization":true,"deviceUDID":"emulator-5554","deviceApiLevel":23,"deviceScreenSize":"1080x1920","deviceScreenDensity":420,"deviceModel":"Android SDK built for x86","deviceManufacturer":"unknown","pixelRatio":2.625,"statBarHeight":63,"viewportRect":{"left":0,"top":63,"width":1080,"height":1731}}}
[HTTP] <-- POST /wd/hub/session 200 6573 ms - 1022
[HTTP]
[HTTP] --> POST /wd/hub/session/3988d8fb-ec0a-4b11-b2aa-4fa5e2be8fa0/timeouts
[HTTP] {"implicit":5000}
[debug] [W3C (3988d8fb)] Encountered internal error running command: NoSuchDriverError: A session is either terminated or not started
[debug] [W3C (3988d8fb)] at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@4.5.1@appium-base-driver/lib/protocol/protocol.js:252:15)
[debug] [W3C (3988d8fb)] at /usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@4.5.1@appium-base-driver/lib/protocol/protocol.js:432:15
[debug] [W3C (3988d8fb)] at Layer.handle [as handle_request] (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/layer.js:95:5)
[debug] [W3C (3988d8fb)] at next (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/route.js:137:13)
[debug] [W3C (3988d8fb)] at Route.dispatch (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/route.js:112:3)
[debug] [W3C (3988d8fb)] at Layer.handle [as handle_request] (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/layer.js:95:5)
[debug] [W3C (3988d8fb)] at /usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:281:22
[debug] [W3C (3988d8fb)] at param (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:354:14)
[debug] [W3C (3988d8fb)] at param (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:365:14)
[debug] [W3C (3988d8fb)] at Function.process_params (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:410:3)
[debug] [W3C (3988d8fb)] at next (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:275:10)
[debug] [W3C (3988d8fb)] at logger (/usr/local/lib/node_modules/appium/node_modules/_morgan@1.10.0@morgan/index.js:144:5)
[debug] [W3C (3988d8fb)] at Layer.handle [as handle_request] (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/layer.js:95:5)
[debug] [W3C (3988d8fb)] at trim_prefix (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:317:13)
[debug] [W3C (3988d8fb)] at /usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:284:7
[debug] [W3C (3988d8fb)] at Function.process_params (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:335:12)
[debug] [W3C (3988d8fb)] at next (/usr/local/lib/node_modules/appium/node_modules/_express@4.17.1@express/lib/router/index.js:275:10)
[debug] [W3C (3988d8fb)] at /usr/local/lib/node_modules/appium/node_modules/_body-parser@1.19.0@body-parser/lib/read.js:130:5
[debug] [W3C (3988d8fb)] at invokeCallback (/usr/local/lib/node_modules/appium/node_modules/_raw-body@2.4.0@raw-body/index.js:224:16)
[debug] [W3C (3988d8fb)] at done (/usr/local/lib/node_modules/appium/node_modules/_raw-body@2.4.0@raw-body/index.js:213:7)
[debug] [W3C (3988d8fb)] at IncomingMessage.onEnd (/usr/local/lib/node_modules/appium/node_modules/_raw-body@2.4.0@raw-body/index.js:273:7)
[debug] [W3C (3988d8fb)] at IncomingMessage.emit (events.js:205:15)
[HTTP] <-- POST /wd/hub/session/3988d8fb-ec0a-4b11-b2aa-4fa5e2be8fa0/timeouts 404 49 ms - 2766
[HTTP]
[BaseDriver] Shutting down because we waited 60 seconds for a command
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched '/' to command name 'deleteSession'
[debug] [WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8202/wd/hub/session/d5394f06-2ad1-4be9-9b15-996a11587f85] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"d5394f06-2ad1-4be9-9b15-996a11587f85","value":null}
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.xueqiu.android'
[debug] [Instrumentation] .
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8202
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp\:8202'
[debug] [Instrumentation] Time: 64.133
[debug] [Instrumentation]
[debug] [Instrumentation] OK (1 test)
[debug] [Instrumentation] The process has exited with code 0
异常:
可以启动雪球,启动后无任何操作,pycharm直接报错,appium到“[HTTP] <-- POST /wd/hub/session/3988d8fb-ec0a-4b11-b2aa-4fa5e2be8fa0/timeouts 404 49 ms - 2766”
这里停止,等待10秒左右雪球退出