• 插耳机不会影响测试结果吗

  • 万分感谢😊

  • 好,万分感谢,晚上回去试试

  • 部分appium-log
    Starting UIAutomator2 server 3.5.1
    [UiAutomator2] Using UIAutomator2 server from 'C:\Users\chen5\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v3.5.1.apk' and test from 'C:\Users\chen5\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk'
    [UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
    [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","mtp62615352326","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
    [WD Proxy] Matched '/status' to command name 'getStatus'
    [WD Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
    [WD Proxy] Got an unexpected response: {"errno":"ECONNRESET","code":"ECONNRESET","syscall":"read"}
    [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
    [WD Proxy] Matched '/status' to command name 'getStatus'
    [WD Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
    [WD Proxy] Got an unexpected response: {"errno":"ECONNRESET","code":"ECONNRESET","syscall":"read"}
    [WD Proxy] Matched '/status' to command name 'getStatus'
    [WD Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
    [WD Proxy] Got response with status 200: "{\"sessionId\":\"None\",\"status\":0,\"value\":\"Status Invoked\"}"
    [WD Proxy] Determined that the downstream protocol for proxy is MJSONWP
    [UiAutomator2] The initialization of the instrumentation process took 3178ms
    [WD Proxy] Matched '/session' to command name 'createSession'
    [WD Proxy] Proxying [POST /session] to [POST http://localhost:8200/wd/hub/session] with body: {"desiredCapabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","platformVersion":"9","deviceName":"GM9","automationName":"uiautomator2","appPackage":"com.google.android.contacts","appActivity":"com.android.contacts.activities.PeopleActivity"},"platformName":"android","platformVersion":"9","deviceName":"mtp62615352326","automationName":"uiautomator2","appPackage":"com.google.android.contacts","appActivity":"com.android.contacts.activities.PeopleActivity","deviceUDID":"mtp62615352326"}}
    [WD Proxy] Got response with status 200: {"sessionId":"ef4d62ec-f76b-44c0-962b-8438c75aa8c2","status":0,"value":"Created Session"}
    [WD Proxy] Proxying [GET /appium/device/info] to [GET http://localhost:8200/wd/hub/session/ef4d62ec-f76b-44c0-962b-8438c75aa8c2/appium/device/info] with no body
    [WD Proxy] Got response with status 200: "{\"sessionId\":\"ef4d62ec-f76b-44c0-962b-8438c75aa8c2\",\"status\":0,\"value\":{\"androidId\":\"920408402bd2ea58\",\"manufacturer\":\"General Mobile\",\"model\":\"GM 9 Pro d\",\"brand\":\"GM\",\"apiVersion\":\"28\",\"platformVersion\":\"9\",\"carrierName\":\"\",\"realDisplaySize\":\"1080x2160\",\"displayDensity\":480,\"networks\":[]}}"
    [ADB] Running 'F:\Tools\android\sdk\platform-tools\adb.exe -P 5037 -s mtp62615352326 shell dumpsys window'
    [AndroidDriver] Screen already unlocked, doing nothing
    [UiAutomator2] UiAutomator2 did not start the activity we were waiting for, 'com.google.android.contacts/com.android.contacts.activities.PeopleActivity'. Starting it ourselves
    [ADB] Running 'F:\Tools\android\sdk\platform-tools\adb.exe -P 5037 -s mtp62615352326 shell am start -W -n com.google.android.contacts/com.android.contacts.activities.PeopleActivity -S'
    [WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://localhost:8200/wd/hub/session/ef4d62ec-f76b-44c0-962b-8438c75aa8c2/appium/device/pixel_ratio] with body: {}
    [WD Proxy] Got response with status 200: "{\"sessionId\":\"ef4d62ec-f76b-44c0-962b-8438c75aa8c2\",\"status\":0,\"value\":3}"
    [WD Proxy] Matched '/appium/device/system_bars' to command name 'getSystemBars'
    [WD Proxy] Proxying [GET /appium/device/system_bars] to [GET http://localhost:8200/wd/hub/session/ef4d62ec-f76b-44c0-962b-8438c75aa8c2/appium/device/system_bars] with body: {}
    [WD Proxy] Got response with status 200: "{\"sessionId\":\"ef4d62ec-f76b-44c0-962b-8438c75aa8c2\",\"status\":0,\"value\":{\"statusBar\":72}}"
    [WD Proxy] Matched '/window/current/size' to command name 'getWindowSize'
    [WD Proxy] Proxying [GET /window/current/size] to [GET http://localhost:8200/wd/hub/session/ef4d62ec-f76b-44c0-962b-8438c75aa8c2/window/current/size] with body: {}
    [WD Proxy] Got response with status 200: "{\"sessionId\":\"ef4d62ec-f76b-44c0-962b-8438c75aa8c2\",\"status\":0,\"value\":{\"height\":2016,\"width\":1080}}"
    [Appium] New AndroidUiautomator2Driver session created successfully, session 7084faeb-b4cd-4b2b-9dd9-8b153a37eab5 added to master session list
    [BaseDriver] Event 'newSessionStarted' logged at 1562860342753 (23:52:22 GMT+0800 (中国标准时间))
    [W3C (7084faeb)] Cached the protocol value 'W3C' for the new session 7084faeb-b4cd-4b2b-9dd9-8b153a37eab5
    [W3C (7084faeb)] 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","platformVersion":"9","deviceName":"GM9","automationName":"uiautomator2","appPackage":"com.google.android.contacts","appActivity":"com.android.contacts.activities.PeopleActivity"},"platformName":"android","platformVersion":"9","deviceName":"mtp62615352326","automationName":"uiautomator2","appPackage":"com.google.android.contacts","appActivity":"com.android.contacts.activities.PeopleActivity","deviceUDID":"mtp62615352326","deviceApiLevel":28,"deviceScreenSize":"1080x2160","deviceScreenDensity":480,"deviceModel":"GM 9 Pro d","deviceManufacturer":"General Mobile","pixelRatio":3,"statBarHeight":72,"viewportRect":{"left":0,"top":72,"width":1080,"height":1944}}}
    [HTTP] <-- POST /wd/hub/session 200 10805 ms - 972
    [HTTP]
    [HTTP] --> POST /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5/timeouts
    [HTTP] {"implicit":5000}
    [W3C (7084faeb)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,5000,"7084faeb-b4cd-4b2b-9dd9-8b153a37eab5"]
    [BaseDriver] W3C timeout argument: {"implicit":5000}}
    [BaseDriver] Set implicit wait to 5000ms
    [W3C (7084faeb)] Responding to client with driver.timeouts() result: null
    [HTTP] <-- POST /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5/timeouts 200 2 ms - 14
    [HTTP]
    [HTTP] --> POST /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5/element
    [HTTP] {"using":"id","value":"android:id/button2"}
    [W3C (7084faeb)] Calling AppiumDriver.findElement() with args: ["id","android:id/button2","7084faeb-b4cd-4b2b-9dd9-8b153a37eab5"]
    [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
    [BaseDriver] Waiting up to 5000 ms for condition
    [WD Proxy] Matched '/element' to command name 'findElement'
    [WD Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/ef4d62ec-f76b-44c0-962b-8438c75aa8c2/element] with body: {"strategy":"id","selector":"android:id/button2","context":"","multiple":false}
    [WD Proxy] Got response with status 200: {"sessionId":"ef4d62ec-f76b-44c0-962b-8438c75aa8c2","status":0,"value":{"ELEMENT":"c5857e55-f287-448f-a9bc-c534f2be420d"}}
    [W3C (7084faeb)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"c5857e55-f287-448f-a9bc-c534f2be420d","ELEMENT":"c5857e55-f287-448f-a9bc-c534f2be420d"}
    [HTTP] <-- POST /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5/element 200 498 ms - 137
    [HTTP]
    [HTTP] --> POST /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5/element/c5857e55-f287-448f-a9bc-c534f2be420d/click
    [HTTP] {"id":"c5857e55-f287-448f-a9bc-c534f2be420d"}
    [W3C (7084faeb)] Calling AppiumDriver.click() with args: ["c5857e55-f287-448f-a9bc-c534f2be420d","7084faeb-b4cd-4b2b-9dd9-8b153a37eab5"]
    [WD Proxy] Matched '/element/c5857e55-f287-448f-a9bc-c534f2be420d/click' to command name 'click'
    [WD Proxy] Proxying [POST /element/c5857e55-f287-448f-a9bc-c534f2be420d/click] to [POST http://localhost:8200/wd/hub/session/ef4d62ec-f76b-44c0-962b-8438c75aa8c2/element/c5857e55-f287-448f-a9bc-c534f2be420d/click] with body: {"element":"c5857e55-f287-448f-a9bc-c534f2be420d"}
    [WD Proxy] Got response with status 200: {"sessionId":"ef4d62ec-f76b-44c0-962b-8438c75aa8c2","status":0,"value":true}
    [W3C (7084faeb)] Responding to client with driver.click() result: true
    [HTTP] <-- POST /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5/element/c5857e55-f287-448f-a9bc-c534f2be420d/click 200 44 ms - 14
    [HTTP]
    [HTTP] --> DELETE /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5
    [HTTP] {}
    [W3C (7084faeb)] Calling AppiumDriver.deleteSession() with args: ["7084faeb-b4cd-4b2b-9dd9-8b153a37eab5"]
    [BaseDriver] Event 'quitSessionRequested' logged at 1562860346310 (23:52:26 GMT+0800 (中国标准时间))
    [Appium] Removing session 7084faeb-b4cd-4b2b-9dd9-8b153a37eab5 from our master session list
    [UiAutomator2] Deleting UiAutomator2 session
    [UiAutomator2] Deleting UiAutomator2 server session
    [WD Proxy] Matched '/' to command name 'deleteSession'
    [WD Proxy] Proxying [DELETE /] to [DELETE http://localhost:8200/wd/hub/session/ef4d62ec-f76b-44c0-962b-8438c75aa8c2] with no body
    [WD Proxy] Got response with status 200: "{\"sessionId\":\"ef4d62ec-f76b-44c0-962b-8438c75aa8c2\",\"status\":0,\"value\":\"Session deleted\"}"
    [ADB] Running 'F:\Tools\android\sdk\platform-tools\adb.exe -P 5037 -s mtp62615352326 shell am force-stop com.google.android.contacts'
    [Logcat] Stopping logcat capture
    [ADB] Removing forwarded port socket connection: 8200
    [ADB] Running 'F:\Tools\android\sdk\platform-tools\adb.exe -P 5037 -s mtp62615352326 forward --remove tcp:8200'
    [UiAutomator2] Restoring hidden api policy to the device default configuration
    [ADB] Running 'F:\Tools\android\sdk\platform-tools\adb.exe -P 5037 -s mtp62615352326 shell settings delete global hidden_api_policy_pre_p_apps'
    [Instrumentation] .
    [ADB] Running 'F:\Tools\android\sdk\platform-tools\adb.exe -P 5037 -s mtp62615352326 shell settings delete global hidden_api_policy_p_apps'
    [Instrumentation] Time: 7.078
    [Instrumentation]
    [Instrumentation] OK (1 test)
    [Instrumentation] The process has exited with code 0
    [ADB] Running 'F:\Tools\android\sdk\platform-tools\adb.exe -P 5037 -s mtp62615352326 shell settings delete global hidden_api_policy'
    [BaseDriver] Event 'quitSessionFinished' logged at 1562860347219 (23:52:27 GMT+0800 (中国标准时间))
    [W3C (7084faeb)] Received response: null
    [W3C (7084faeb)] But deleting session, so not returning
    [W3C (7084faeb)] Responding to client with driver.deleteSession() result: null
    [HTTP] <-- DELETE /wd/hub/session/7084faeb-b4cd-4b2b-9dd9-8b153a37eab5 200 910 ms - 14
    [HTTP]

  • 我试过这个,这种装饰好后,是可以直接运行,不用到Pytest. ini中去配置,这个在配置文件中的貌似不用添加额外的装饰,配置文件是方便分组,减少装饰代码重复,你说的是单纯的mark

  • 求大神指导

  • Author only
  • alert弹框,alert=d.switch_to_alert(),通过alert对象查找元素

  • 换浏览器,不要用谷歌

  • 感谢大佬们提示,改天拿冒烟用例试试手😃