'Appium: Super slow Robot Framework automated tests (Xiaomi)
I have a simple test app (react-native) with a few buttons, that invoke a toast message. I wrote simple test cases in Robot Framework to click on the individual buttons and then wait for the toast to show up.
Everything was running well until last week. The tests became unusably slow (every interaction takes too much time). Normally a tap took a second or two, now it can take up to minute. Only the start initial connection and start of the application is normal.
I am running the tests on a local machine (Mac) with a real device (Xiaomi).
Setup:
- Appium: 1.22.2
- Robot Framework 4.1.3 (Python 3.9.10 on darwin)
- MacOS 12.2.1
- Phone: Xiaomi Redmi Note 7
- Android: 10
- MIUI: 12.5.3
When I run the tests on a different device (Samsung), it works just fine. (using that other device isn't a solution, the device isn't mine)
Here is my Suite Setup:
***Keywords***
Start App
&{deviceConfig}= Create Dictionary
Set To Dictionary ${deviceConfig} platformName=android
Set To Dictionary ${deviceConfig} platformVersion=10
Set To Dictionary ${deviceConfig} udid=c15dded3
Set To Dictionary ${deviceConfig} appPackage=com.toastexamplestest
Set To Dictionary ${deviceConfig} appActivity=.MainActivity
Set To Dictionary ${deviceConfig} automationName=uiautomator2
Open Application http://127.0.0.1:4723/wd/hub &{deviceConfig}
Here is one of the test cases:
React native root toast
Tap ${btn_root_toast}
Wait For Error //android.view.ViewGroup/android.widget.TextView[contains(@text, '${toast_text_root_toast}' )]
Sleep 5s
Tap ${btn_root_toast}
Wait For Error //android.view.ViewGroup/android.widget.TextView[contains(@text, '${toast_text_root_toast}' )]
(Wait For Error is just a wrapper for Wait Until Page Contains Element)
Test Setup is just Launch Application
and Test Teardown is just Quit Application
Appium Logs:
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
...
[BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[BaseDriver] Creating session with W3C capabilities: {
[BaseDriver] "alwaysMatch": {
[BaseDriver] "platformName": "android",
[BaseDriver] "appium:platformVersion": "10",
[BaseDriver] "appium:udid": "c15dded3",
[BaseDriver] "appium:appPackage": "com.toastexamplestest",
[BaseDriver] "appium:appActivity": ".MainActivity",
[BaseDriver] "appium:automationName": "uiautomator2"
[BaseDriver] },
[BaseDriver] "firstMatch": [
[BaseDriver] {}
[BaseDriver] ]
[BaseDriver] }
[BaseDriver] Session created with session id: d97552ab-31db-42f1-b98d-d23549f2efde
[UiAutomator2] Starting 'com.toastexamplestest' directly on the device
[ADB] Using 'adb' from '/Users/marekd/Library/Android/sdk/platform-tools/adb'
...
[ADB] Connected devices: [{"udid":"c15dded3","state":"device"}]
[AndroidDriver] Using device: c15dded3
...
[WD Proxy] socket hang up
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] Got response with status 200: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
[UiAutomator2] The initialization of the instrumentation process took 3080ms
...
[HTTP] <-- POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/appium/app/launch 200 963 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/elements
[HTTP] {"using":"xpath","value":"//android.widget.Button[1]"}
[W3C (d97552ab)] Calling AppiumDriver.findElements() with args: ["xpath","//android.widget.Button[1]","d97552ab-31db-42f1-b98d-d23549f2efde"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched '/elements' to command name 'findElements'
[WD Proxy] Proxying [POST /elements] to [POST http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/elements] with body: {"strategy":"xpath","selector":"//android.widget.Button[1]","context":"","multiple":true}
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4-90de-bbc34238a12a","value":[{"ELEMENT":"00000000-0000-0049-ffff-ffff00000011","element-6066-11e4-a52e-4f735466cecf":"00000000-0000-0049-ffff-ffff00000011"}]}
[W3C (d97552ab)] Responding to client with driver.findElements() result: [{"element-6066-11e4-a52e-4f735466cecf":"00000000-0000-0049-ffff-ffff00000011","ELEMENT":"00000000-0000-0049-ffff-ffff00000011"}]
[HTTP] <-- POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/elements 200 10355 ms - 139
[HTTP]
[HTTP] --> POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/touch/perform
[HTTP] {"actions":[{"action":"tap","options":{"element":"00000000-0000-0049-ffff-ffff00000011","count":1}}]}
[W3C (d97552ab)] Calling AppiumDriver.performTouch() with args: [[{"action":"tap","options":{"element":"00000000-0000-0049-ffff-ffff00000011","count":1}}],"d97552ab-31db-42f1-b98d-d23549f2efde"]
[UiAutomator2] calling get location: 00000000-0000-0049-ffff-ffff00000011
[WD Proxy] Matched '/element/00000000-0000-0049-ffff-ffff00000011/location' to command name 'getLocation'
[WD Proxy] Proxying [GET /element/00000000-0000-0049-ffff-ffff00000011/location] to [GET http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/element/00000000-0000-0049-ffff-ffff00000011/location] with no body
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4-90de-bbc34238a12a","value":{"x":11,"y":832}}
[WD Proxy] Matched '/element/00000000-0000-0049-ffff-ffff00000011/size' to command name 'getSize'
[WD Proxy] Proxying [GET /element/00000000-0000-0049-ffff-ffff00000011/size] to [GET http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/element/00000000-0000-0049-ffff-ffff00000011/size] with no body
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4-90de-bbc34238a12a","value":{"height":97,"width":1058}}
[WD Proxy] Proxying [POST /appium/tap] to [POST http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/appium/tap] with body: {"x":540,"y":880.5,"undefined":null}
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4-90de-bbc34238a12a","value":null}
[W3C (d97552ab)] Responding to client with driver.performTouch() result: null
[HTTP] <-- POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/touch/perform 200 50417 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/elements
[HTTP] {"using":"xpath","value":"//android.view.ViewGroup/android.widget.TextView[contains(@text, 'This is a message' )]"}
[W3C (d97552ab)] Calling AppiumDriver.findElements() with args: ["xpath","//android.view.ViewGroup/android.widget.TextView[contains(@text, 'This is a message' )]","d97552ab-31db-42f1-b98d-d23549f2efde"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched '/elements' to command name 'findElements'
[WD Proxy] Proxying [POST /elements] to [POST http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/elements] with body: {"strategy":"xpath","selector":"//android.view.ViewGroup/android.widget.TextView[contains(@text, 'This is a message' )]","context":"","multiple":true}
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4-90de-bbc34238a12a","value":[]}
[W3C (d97552ab)] Responding to client with driver.findElements() result: []
[HTTP] <-- POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/elements 200 10093 ms - 12
[HTTP]
[HTTP] --> POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/elements
[HTTP] {"using":"xpath","value":"//android.view.ViewGroup/android.widget.TextView[contains(@text, 'This is a message' )]"}
[W3C (d97552ab)] Calling AppiumDriver.findElements() with args: ["xpath","//android.view.ViewGroup/android.widget.TextView[contains(@text, 'This is a message' )]","d97552ab-31db-42f1-b98d-d23549f2efde"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched '/elements' to command name 'findElements'
[WD Proxy] Proxying [POST /elements] to [POST http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/elements] with body: {"strategy":"xpath","selector":"//android.view.ViewGroup/android.widget.TextView[contains(@text, 'This is a message' )]","context":"","multiple":true}
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4-90de-bbc34238a12a","value":[]}
[W3C (d97552ab)] Responding to client with driver.findElements() result: []
[HTTP] <-- POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/elements 200 10083 ms - 12
[HTTP]
[HTTP] --> GET /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/source
[HTTP] {}
[W3C (d97552ab)] Driver proxy active, passing request on via HTTP proxy
[WD Proxy] Matched '/wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/source' to command name 'getPageSource'
[WD Proxy] Proxying [GET /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/source] to [GET http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/source] with no body
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4-90de-bbc34238a12a","value":"\r\n\r\n \r\n \r\n
[WD Proxy] Replacing sessionId cae5d25f-d594-4ec4-90de-bbc34238a12a with d97552ab-31db-42f1-b98d-d23549f2efde
[HTTP] <-- GET /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/source 200 10186 ms - 10712
[HTTP]
[HTTP] --> GET /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/screenshot
[HTTP] {}
[W3C (d97552ab)] Calling AppiumDriver.getScreenshot() with args: ["d97552ab-31db-42f1-b98d-d23549f2efde"]
[WD Proxy] Matched '/screenshot' to command name 'getScreenshot'
[WD Proxy] Proxying [GET /screenshot] to [GET http://127.0.0.1:8200/wd/hub/session/cae5d25f-d594-4ec4-90de-bbc34238a12a/screenshot] with no body
[WD Proxy] Got response with status 200: {"sessionId":"cae5d25f-d594-4ec4...
[W3C (d97552ab)] Responding to client with driver.getScreenshot() result: "iVBORw0K...
[HTTP] <-- GET /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/screenshot 200 608 ms - 140626
[HTTP]
[HTTP] --> POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/appium/app/close
[HTTP] {}
[W3C (d97552ab)] Calling AppiumDriver.closeApp() with args: ["d97552ab-31db-42f1-b98d-d23549f2efde"]
[ADB] Running '/Users/marekd/Library/Android/sdk/platform-tools/adb -P 5037 -s c15dded3 shell am force-stop com.toastexamplestest'
[W3C (d97552ab)] Responding to client with driver.closeApp() result: null
[HTTP] <-- POST /wd/hub/session/d97552ab-31db-42f1-b98d-d23549f2efde/appium/app/close 200 86 ms - 14
The log isn't complete, couldn't fit it all here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
