我启动后两个都可以打开慕课网进入登陆界面
模拟器1输入账号密码登录模拟器2就报错说找不到页面元素没法输入账号密码
有时两个反过来模拟器2找得到模拟器1找不到
这是base_driver的代码
class BaseDriver():
def android_driver(self, i):
ini = ReadIni(node=“server_port”, file_name=r"D:\测试\自动化测试\App自动化测试\Appnium\config\userconfig.ini")
deviceName = ini.get_value(“devices” + str(i))
port = ini.get_value(“appium_port” + str(i))
capabilities = {
“platformName”: “Android”,
“automationName”: “UiAutomator2”,
“deviceName”: deviceName,
“app”: “D:\测试\APPnium\mukewang.apk”,
“noReset”: “true”
}
driver = webdriver.Remote(“127.0.0.1:” + port +"/wd/hub", capabilities)
time.sleep(5)
return driver
这是case页面的代码
class ParamTestCase(unittest.TestCase):
def init(self, methodName=‘runTest’, param=None):
super(ParamTestCase, self).init(methodName)
self.param = param
global params
params = param
class LoginCaseTest(ParamTestCase):
@classmethod
def setUpClass(cls):
base_driver = BaseDriver()
cls.driver = base_driver.android_driver(params)
time.sleep(10)
cls.login_business = LoginBusiness(cls.driver)
def test_login_pass(self):
self.login_business.login_pass()
def get_suite(i):
suite = unittest.TestSuite()
# for name in testnames:
suite.addTest(LoginCaseTest(“test_login_pass”, param=i))
unittest.TextTestRunner().run(suite)
if name == “main”:
se = Server()
se.start_server_thread()
threads = []
for i in range(2):
t = threading.Thread(target=get_suite, args=(i,))
threads.append(t)
for j in threads:
j.start()
这是部分日志
[AndroidDriver] Granting android.permission.SET_ANIMATION_SCALE, CHANGE_CONFIGURATION, ACCESS_FINE_LOCATION by pm grant
[debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[debug] [ADB] Granting permissions [“android.permission.SET_ANIMATION_SCALE”,“android.permission.CHANGE_CONFIGURATION”,“android.permission.ACCESS_FINE_LOCATION”] to ‘io.appium.settings’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell settings put secure mock_location 1’
[debug] [ADB] Got the following command chunks to execute: [[“pm”,“grant”,“io.appium.settings”,“android.permission.SET_ANIMATION_SCALE”,";",“pm”,“grant”,“io.appium.settings”,“android.permission.CHANGE_CONFIGURATION”,";",“pm”,“grant”,“io.appium.settings”,“android.permission.ACCESS_FINE_LOCATION”,";"]]
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell pm grant io.appium.settings android.permission.SET_ANIMATION_SCALE ; pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION ; pm grant io.appium.settings android.permission.ACCESS_FINE_LOCATION ;’
[debug] [Logcat] Starting logcat capture
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 forward tcp:8200 tcp:6790’
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell dumpsys package io.appium.uiautomator2.server’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell am start -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER’
[debug] [ADB] ‘io.appium.uiautomator2.server’ is installed
[debug] [ADB] Getting package info for ‘io.appium.uiautomator2.server’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 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.5.5’ >= ‘4.5.5’)
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[debug] [ADB] Checking app cert for D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-v4.5.5.apk
[ADB] Found 0 ‘build-tools’ folders under ‘’ (newest first):
[ADB] Cannot use apksigner tool for signature verification. Original error: Could not find ‘apksigner.bat’ in [“D:\测试\自动化测试\App自动化测试\Appnium\case\platform-tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\emulator\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\bin\apksigner.bat”]. Do you have Android Build Tools installed at ‘’?
[debug] [ADB] Defaulting to verify.jar
[debug] [ADB] ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-v4.5.5.apk’ is already signed.
[debug] [ADB] Getting install status for io.appium.uiautomator2.server.test
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell dumpsys package io.appium.uiautomator2.server.test’
[debug] [ADB] ‘io.appium.uiautomator2.server.test’ is installed
[debug] [ADB] Checking app cert for D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-debug-androidTest.apk
[ADB] Cannot use apksigner tool for signature verification. Original error: Could not find ‘apksigner.bat’ in [“D:\测试\自动化测试\App自动化测试\Appnium\case\platform-tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\emulator\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\bin\apksigner.bat”]. Do you have Android Build Tools installed at ‘’?
[debug] [ADB] Defaulting to verify.jar
[debug] [ADB] ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-debug-androidTest.apk’ is already signed.
[UiAutomator2] Server packages are not going to be (re)installed
[debug] [UiAutomator2] Waiting up to 30000ms for services to be available
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell pm list instrumentation’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Using ps-based PID detection
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell ps’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell settings put secure mock_location 1’
[debug] [UiAutomator2] Instrumentation target ‘io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner’ is available
[debug] [ADB] Checking app cert for D:测试APPniummukewang.apk
[ADB] Cannot use apksigner tool for signature verification. Original error: Could not find ‘apksigner.bat’ in [“D:\测试\自动化测试\App自动化测试\Appnium\case\platform-tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\emulator\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\bin\apksigner.bat”]. Do you have Android Build Tools installed at ‘’?
[debug] [ADB] Defaulting to verify.jar
[debug] [Logcat] Starting logcat capture
[debug] [ADB] ‘D:测试APPniummukewang.apk’ is already signed.
[debug] [ADB] Getting install status for cn.com.open.mooc
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell dumpsys package cn.com.open.mooc’
[debug] [ADB] ‘cn.com.open.mooc’ is installed
[debug] [ADB] Getting package info for ‘cn.com.open.mooc’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell dumpsys package cn.com.open.mooc’
[debug] [ADB] The version name of the installed ‘cn.com.open.mooc’ is greater or equal to the application version name (‘5.1.2’ >= ‘5.1.2’)
[debug] [ADB] There is no need to install/upgrade ‘D:测试APPniummukewang.apk’
[debug] [UiAutomator2] Performing shallow cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected (Error: read ECONNRESET)
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell am force-stop io.appium.uiautomator2.server.test’
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8201
[debug] [ADB] Forwarding system: 8201 to device: 6790
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 forward tcp:8201 tcp:6790’
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 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 ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 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.5.5’ >= ‘4.5.5’)
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[debug] [ADB] Checking app cert for D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-v4.5.5.apk
[ADB] Found 0 ‘build-tools’ folders under ‘’ (newest first):
[ADB] Cannot use apksigner tool for signature verification. Original error: Could not find ‘apksigner.bat’ in [“D:\测试\自动化测试\App自动化测试\Appnium\case\platform-tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\emulator\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\bin\apksigner.bat”]. Do you have Android Build Tools installed at ‘’?
[debug] [ADB] Defaulting to verify.jar
[debug] [ADB] ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-v4.5.5.apk’ is already signed.
[debug] [ADB] Getting install status for io.appium.uiautomator2.server.test
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell dumpsys package io.appium.uiautomator2.server.test’
[debug] [ADB] ‘io.appium.uiautomator2.server.test’ is installed
[debug] [ADB] Checking app cert for D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-debug-androidTest.apk
[ADB] Cannot use apksigner tool for signature verification. Original error: Could not find ‘apksigner.bat’ in [“D:\测试\自动化测试\App自动化测试\Appnium\case\platform-tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\emulator\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\bin\apksigner.bat”]. Do you have Android Build Tools installed at ‘’?
[debug] [ADB] Defaulting to verify.jar
[UiAutomator2] Starting UIAutomator2 server 4.5.5
[UiAutomator2] Using UIAutomator2 server from ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-v4.5.5.apk’ and test from ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-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",“127.0.0.1:62001”,“shell”,“am”,“instrument”,"-w",“io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner”]
[debug] [ADB] ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-debug-androidTest.apk’ is already signed.
[UiAutomator2] Server packages are not going to be (re)installed
[debug] [UiAutomator2] Waiting up to 30000ms for services to be available
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell pm list instrumentation’
[debug] [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
[debug] [UiAutomator2] Instrumentation target ‘io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner’ is available
[debug] [ADB] Checking app cert for D:测试APPniummukewang.apk
[ADB] Cannot use apksigner tool for signature verification. Original error: Could not find ‘apksigner.bat’ in [“D:\测试\自动化测试\App自动化测试\Appnium\case\platform-tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\emulator\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\apksigner.bat”,“D:\测试\自动化测试\App自动化测试\Appnium\case\tools\bin\apksigner.bat”]. Do you have Android Build Tools installed at ‘’?
[debug] [ADB] Defaulting to verify.jar
[debug] [ADB] ‘D:测试APPniummukewang.apk’ is already signed.
[debug] [ADB] Getting install status for cn.com.open.mooc
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell dumpsys package cn.com.open.mooc’
[debug] [WD Proxy] Matched ‘/status’ to command name ‘getStatus’
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {“errno”:“ECONNRESET”,“code”:“ECONNRESET”,“syscall”:“read”}
[debug] [ADB] ‘cn.com.open.mooc’ is installed
[debug] [ADB] Getting package info for ‘cn.com.open.mooc’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell dumpsys package cn.com.open.mooc’
[debug] [ADB] The version name of the installed ‘cn.com.open.mooc’ is greater or equal to the application version name (‘5.1.2’ >= ‘5.1.2’)
[debug] [ADB] There is no need to install/upgrade ‘D:测试APPniummukewang.apk’
[debug] [UiAutomator2] Performing shallow cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected (Error: read ECONNRESET)
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell am force-stop io.appium.uiautomator2.server.test’
[UiAutomator2] Starting UIAutomator2 server 4.5.5
[UiAutomator2] Using UIAutomator2 server from ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-uiautomator2-server-v4.5.5.apk’ and test from ‘D:
odejs
ode_global
ode_modulesappium
ode_modules_appium-uiautomator2-server@4.5.5@appium-uiautomator2-serverapksappium-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",“127.0.0.1:62025”,“shell”,“am”,“instrument”,"-w",“io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner”]
[debug] [WD Proxy] Matched ‘/status’ to command name ‘getStatus’
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“None”,“value”:{“ready”:true,“message”:“UiAutomator2 Server is ready to accept commands”}}
[debug] [UiAutomator2] The initialization of the instrumentation process took 2022ms
[debug] [WD Proxy] Matched ‘/session’ to command name ‘createSession’
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8200/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”,“udid”:“127.0.0.1:62001”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62001”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true},“platformName”:“Android”,“udid”:“127.0.0.1:62001”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62001”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true,“deviceUDID”:“127.0.0.1:62001”,“appPackage”:“cn.com.open.mooc”}],“alwaysMatch”:{}}}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“da21a83c-c304-4fbd-9138-317a8c0fed70”,“value”:{“sessionId”:“da21a83c-c304-4fbd-9138-317a8c0fed70”,“capabilities”:{“firstMatch”:[{“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“platformName”:“Android”,“udid”:“127.0.0.1:62001”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62001”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true},“platformName”:“Android”,“udid”:“127.0.0.1:62001”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62001”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true,“deviceUDID”:“127.0.0.1:62001”,“appPackage”:“cn.com.open.mooc”}],“alwaysMatch”:{}}}}
[WD Proxy] Determined the downstream protocol as ‘W3C’
[debug] [WD Proxy] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8200/wd/hub/session/da21a83c-c304-4fbd-9138-317a8c0fed70/appium/device/info] with no body
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“da21a83c-c304-4fbd-9138-317a8c0fed70”,“value”:{“androidId”:“b4b686d23a9a6886”,“manufacturer”:“HUAWEI”,“model”:“HUAWEI MLA-AL10”,“brand”:“HUAWEI”,“apiVersion”:“22”,“platformVersion”:“5.1.1”,“carrierName”:“CHINA MOBILE”,“realDisplaySize”:“900x1600”,“displayDensity”:320,“networks”:[{“type”:1,“typeName”:“WIFI”,“subtype”:0,“subtypeName”:"",“isConnected”:true,“detailedState”:“CONNECTED”,“state”:“CONNECTED”,“extraInfo”:"“WiredSSID”",“isAvailable”:true,“isFailover”:false,“isRoaming”:false,“capabilities”:{“transportTypes”:“TRANSPORT_WIFI”,“networkCapabilities”:“NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_INTERNET,NET_CAPABILITY_TRUSTED”,“linkUpstreamBandwidthKbps”:1048576,“linkDownBandwidthKbps”:1048576,“signalStrength”:null,“networkSpecifier”:null,“SSID”:null}}],“locale”:“zh_CN”,“timeZone”:“Asia/Shanghai”,“bluetooth”:{“state”:“OFF”}}}
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell dumpsys window’
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'cn.com.open.mooc/cn.com.open.mooc.index.splash.MCSplashActivity and waiting for ‘cn.com.open.mooc/cn.com.open.mooc.index.splash.MCSplashActivity’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell am start -W -n cn.com.open.mooc/cn.com.open.mooc.index.splash.MCSplashActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000’
[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:8201/wd/hub/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {“errno”:“ECONNRESET”,“code”:“ECONNRESET”,“syscall”:“read”}
[debug] [ADB] Waiting up to 20000ms for activity matching pkg: ‘cn.com.open.mooc’ and activity: ‘cn.com.open.mooc.index.splash.MCSplashActivity’ to be focused
[debug] [ADB] Possible activities, to be checked: ‘cn.com.open.mooc.index.splash.MCSplashActivity’, ‘cn.com.open.mooc.cn.com.open.mooc.index.splash.MCSplashActivity’
[debug] [ADB] Getting focused package and activity
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell dumpsys window windows’
[debug] [ADB] Found package: ‘cn.com.open.mooc’ and fully qualified activity name : ‘cn.com.open.mooc.index.splash.MCSplashActivity’
[debug] [WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8200/wd/hub/session/da21a83c-c304-4fbd-9138-317a8c0fed70/appium/device/pixel_ratio] with body: {}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“da21a83c-c304-4fbd-9138-317a8c0fed70”,“value”:2}
[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:8200/wd/hub/session/da21a83c-c304-4fbd-9138-317a8c0fed70/appium/device/system_bars] with body: {}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“da21a83c-c304-4fbd-9138-317a8c0fed70”,“value”:{“statusBar”:50}}
[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:8200/wd/hub/session/da21a83c-c304-4fbd-9138-317a8c0fed70/window/current/size] with body: {}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“da21a83c-c304-4fbd-9138-317a8c0fed70”,“value”:{“height”:1600,“width”:900}}
[Appium] New AndroidUiautomator2Driver session created successfully, session 45014a2a-2eb0-46b3-a2de-37db0165f5a9 added to master session list
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1581828864009 (12:54:24 GMT+0800 (GMT+08:00))
[debug] [W3C (45014a2a)] Cached the protocol value ‘W3C’ for the new session 45014a2a-2eb0-46b3-a2de-37db0165f5a9
[debug] [W3C (45014a2a)] 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”,“udid”:“127.0.0.1:62001”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62001”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true},“platformName”:“Android”,“udid”:“127.0.0.1:62001”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62001”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true,“deviceUDID”:“127.0.0.1:62001”,“appPackage”:“cn.com.open.mooc”,“deviceApiLevel”:22,“platformVersion”:“5.1.1”,“deviceScreenSize”:“900x1600”,“deviceScreenDensity”:320,“deviceModel”:“HUAWEI MLA-AL10”,“deviceManufacturer”:“HUAWEI”,“pixelRatio”:2,“statBarHeight”:50,“viewportRect”:{“left”:0,“top”:50,“width”:900,“height”:1550}}}
[HTTP] <-- POST /wd/hub/session 200 6751 ms - 947
[HTTP]
[debug] [WD Proxy] Matched ‘/status’ to command name ‘getStatus’
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8201/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“None”,“value”:{“ready”:true,“message”:“UiAutomator2 Server is ready to accept commands”}}
[debug] [UiAutomator2] The initialization of the instrumentation process took 2058ms
[debug] [WD Proxy] Matched ‘/session’ to command name ‘createSession’
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8201/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”,“udid”:“127.0.0.1:62025”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62025”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true},“platformName”:“Android”,“udid”:“127.0.0.1:62025”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62025”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true,“deviceUDID”:“127.0.0.1:62025”,“appPackage”:“cn.com.open.mooc”}],“alwaysMatch”:{}}}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3”,“value”:{“sessionId”:“93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3”,“capabilities”:{“firstMatch”:[{“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“platformName”:“Android”,“udid”:“127.0.0.1:62025”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62025”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true},“platformName”:“Android”,“udid”:“127.0.0.1:62025”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62025”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true,“deviceUDID”:“127.0.0.1:62025”,“appPackage”:“cn.com.open.mooc”}],“alwaysMatch”:{}}}}
[WD Proxy] Determined the downstream protocol as ‘W3C’
[debug] [WD Proxy] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8201/wd/hub/session/93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3/appium/device/info] with no body
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3”,“value”:{“androidId”:“1b4b686d23a9a730”,“manufacturer”:“Xiaomi”,“model”:“MI 9”,“brand”:“Xiaomi”,“apiVersion”:“22”,“platformVersion”:“5.1.1”,“carrierName”:“CHINA MOBILE”,“realDisplaySize”:“900x1600”,“displayDensity”:320,“networks”:[{“type”:1,“typeName”:“WIFI”,“subtype”:0,“subtypeName”:"",“isConnected”:true,“detailedState”:“CONNECTED”,“state”:“CONNECTED”,“extraInfo”:"“WiredSSID”",“isAvailable”:true,“isFailover”:false,“isRoaming”:false,“capabilities”:{“transportTypes”:“TRANSPORT_WIFI”,“networkCapabilities”:“NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_INTERNET,NET_CAPABILITY_TRUSTED”,“linkUpstreamBandwidthKbps”:1048576,“linkDownBandwidthKbps”:1048576,“signalStrength”:null,“networkSpecifier”:null,“SSID”:null}}],“locale”:“zh_CN”,“timeZone”:“Asia/Shanghai”,“bluetooth”:{“state”:“OFF”}}}
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell dumpsys window’
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'cn.com.open.mooc/cn.com.open.mooc.index.splash.MCSplashActivity and waiting for ‘cn.com.open.mooc/cn.com.open.mooc.index.splash.MCSplashActivity’
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell am start -W -n cn.com.open.mooc/cn.com.open.mooc.index.splash.MCSplashActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000’
[debug] [ADB] Waiting up to 20000ms for activity matching pkg: ‘cn.com.open.mooc’ and activity: ‘cn.com.open.mooc.index.splash.MCSplashActivity’ to be focused
[debug] [ADB] Possible activities, to be checked: ‘cn.com.open.mooc.index.splash.MCSplashActivity’, ‘cn.com.open.mooc.cn.com.open.mooc.index.splash.MCSplashActivity’
[debug] [ADB] Getting focused package and activity
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62025 shell dumpsys window windows’
[debug] [ADB] Found package: ‘cn.com.open.mooc’ and fully qualified activity name : ‘cn.com.open.mooc.index.splash.MCSplashActivity’
[debug] [WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8201/wd/hub/session/93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3/appium/device/pixel_ratio] with body: {}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3”,“value”:2}
[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:8201/wd/hub/session/93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3/appium/device/system_bars] with body: {}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3”,“value”:{“statusBar”:50}}
[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:8201/wd/hub/session/93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3/window/current/size] with body: {}
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“93eb6b2b-e550-41d3-a0ec-3d7d5f5e88e3”,“value”:{“height”:1600,“width”:900}}
[Appium] New AndroidUiautomator2Driver session created successfully, session e865f30f-d902-4705-84a8-931af42f00b4 added to master session list
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1581828866005 (12:54:26 GMT+0800 (GMT+08:00))
[debug] [W3C (e865f30f)] Cached the protocol value ‘W3C’ for the new session e865f30f-d902-4705-84a8-931af42f00b4
[debug] [W3C (e865f30f)] 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”,“udid”:“127.0.0.1:62025”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62025”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true},“platformName”:“Android”,“udid”:“127.0.0.1:62025”,“automationName”:“UiAutomator2”,“deviceName”:“127.0.0.1:62025”,“app”:“D:\测试\APPnium\mukewang.apk”,“noReset”:true,“deviceUDID”:“127.0.0.1:62025”,“appPackage”:“cn.com.open.mooc”,“deviceApiLevel”:22,“platformVersion”:“5.1.1”,“deviceScreenSize”:“900x1600”,“deviceScreenDensity”:320,“deviceModel”:“MI 9”,“deviceManufacturer”:“Xiaomi”,“pixelRatio”:2,“statBarHeight”:50,“viewportRect”:{“left”:0,“top”:50,“width”:900,“height”:1550}}}
[HTTP] <-- POST /wd/hub/session 200 8747 ms - 936
Traceback (most recent call last):
File “D:测试自动化测试App自动化测试Appniumpagesase_page.py”, line 34, in get_element
return WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(locator))
File “C:Users刘杰AppDataLocalProgramsPythonPython37libsite-packagesseleniumwebdriversupportwait.py”, line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:/测试/自动化测试/App自动化测试/Appnium/case/login_case.py”, line 35, in test_login_pass
self.login_business.login_pass()
File “D:测试自动化测试App自动化测试AppniumBusinesslogin_business.py”, line 29, in login_pass
self.login_handle.send_username(‘15226499639’)
File “D:测试自动化测试App自动化测试Appniumhandlelogin_handle.py”, line 14, in send_username
self.login_page.get_username_element().send_keys(username)
File “D:测试自动化测试App自动化测试Appniumpageslogin_page.py”, line 18, in get_username_element
return self.base.get_element(“username”)
File “D:测试自动化测试App自动化测试Appniumpagesase_page.py”, line 37, in get_element
raise TimeoutException(msg=“定位元素失败定位方式是:{}”.format(locator))
selenium.common.exceptions.TimeoutException: Message: 定位元素失败定位方式是:(‘id’, ‘cn.com.open.mooc:id/account_edit’)
Ran 1 test in 33.858s
FAILED (errors=1)
[BaseDriver] Shutting down because we waited 60 seconds for a command
[Appium] Closing session, cause was ‘New Command Timeout of 60 seconds expired. Try customizing the timeout using the ‘newCommandTimeout’ desired capability’
[Appium] Removing session ‘45014a2a-2eb0-46b3-a2de-37db0165f5a9’ from our master session list
[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:8200/wd/hub/session/da21a83c-c304-4fbd-9138-317a8c0fed70] with no body
[debug] [WD Proxy] Got response with status 200: {“sessionId”:“da21a83c-c304-4fbd-9138-317a8c0fed70”,“value”:null}
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 shell am force-stop cn.com.open.mooc’
[debug] [Instrumentation] .
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running ‘D:sdkplatform-toolsadb.exe -P 5037 -s 127.0.0.1:62001 forward --remove tcp:8200’
[debug] [Instrumentation] OK (1 test)
[debug] [Instrumentation] The process has exited with code 0