Appium unable to take screenshot on xCode 13.3 and iOS 15.4 - appium

I woke a few days ago to run an appium UI automated test on iOS simulator which has been running perfectly without any error. I recently upgraded to iOS 15.4 and iOS 13.3 and to my surprise Appium is unable to take screenshots again. I tried checking what the cause could be and found exact similar problem posted here Socket hang up error while taking screenshot in appium (iOS 15.4 beta & xCode 13.3 beta 2). I find this as well on Apple post Xcode 12 Beta 3 Release Notes. Are there any workaround presently for this?
This is the error I'm getting
[HTTP] --> GET /wd/hub/session/ea84cef2-3649-4e76-91b9-23cec159e3a1/element/1B000000-0000-0000-1439-000000000000/screenshot
[HTTP] {}
[debug] [W3C (ea84cef2)] Calling AppiumDriver.getElementScreenshot() with args: ["1B000000-0000-0000-1439-000000000000","ea84cef2-3649-4e76-91b9-23cec159e3a1"]
[debug] [XCUITest] Executing command 'getElementScreenshot'
[debug] [WD Proxy] Matched '/element/1B000000-0000-0000-1439-000000000000/screenshot' to command name 'getElementScreenshot'
[debug] [Protocol Converter] Did not know how to rewrite the original URL '/element/1B000000-0000-0000-1439-000000000000/screenshot' for W3C protocol
[debug] [WD Proxy] Proxying [GET /element/1B000000-0000-0000-1439-000000000000/screenshot] to [GET http://127.0.0.1:8100/session/88FE5109-F180-482B-B948-980F345404CC/element/1B000000-0000-0000-1439-000000000000/screenshot] with no body
[WD Proxy] Got response with status 500: {"value":{"error":"unable to capture screen","message":"Error Domain=com.facebook.WebDriverAgent Code=1 \"Cannot take a screenshot within 20000 ms timeout\" UserInfo={NSLocalizedDescription=Cannot take a screenshot within 20000 ms timeout}","traceback":""},"sessionId":"88FE5109-F180-482B-B948-980F345404CC"}
[debug] [W3C] Matched W3C error code 'unable to capture screen' to UnableToCaptureScreen
[debug] [W3C (ea84cef2)] Encountered internal error running command: UnableToCaptureScreen: Error Domain=com.facebook.WebDriverAgent Code=1 "Cannot take a screenshot within 20000 ms timeout" UserInfo={NSLocalizedDescription=Cannot take a screenshot within 20000 ms timeout}
[debug] [W3C (ea84cef2)] at errorFromW3CJsonCode (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)
[debug] [W3C (ea84cef2)] at ProxyRequestError.getActualError (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)
[debug] [W3C (ea84cef2)] at JWProxy.command (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:272:19)
[debug] [W3C (ea84cef2)] at runMicrotasks (<anonymous>)
[debug] [W3C (ea84cef2)] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[debug] [W3C (ea84cef2)] at XCUITestDriver.proxyCommand (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)
[debug] [W3C (ea84cef2)] at XCUITestDriver.getElementScreenshot (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-xcuitest-driver/lib/commands/screenshots.js:52:16)
[HTTP] <-- GET /wd/hub/session/ea84cef2-3649-4e76-91b9-23cec159e3a1/element/1B000000-0000-0000-1439-000000000000/screenshot 500 20106 ms - 1319

Change back to iOS 15.2 I had the same issue and struggled for hours... tried everything.. It was absolutely the same case as yours. Yesterday it was working and suddenly today it stopped working. So at the end, the only change was that the xcode simulator updated itself to iOS 15.4 from 15.2. That's why somehow appium inspector stopped working and taking screenshots. I guess it will take some time from appium side things to be updated but until then just row back to latest stable iOS simulator version 15.2. How to do that - Xcode -> Preferences -> Components -> select older iOS version Simulator -> download, Check and Install now -> build -> voila :)

It can be fixed by changing WebDriverAgentLib/Utilities/FBScreenshot.m (257th line):
(nullable id)screenshotRequestWithScreenID:(unsigned int)screenID
to:
(nullable id)screenshotRequestWithScreenID:(long long)screenID
Problem is reported and it’s solution is also here:
https://github.com/appium/appium/issues/16604

Related

The app opens and closes 3 times while starting appium

I'm experiencing something strange and can't find any information on the net about it.
I'm starting to develop automation for the iOS OS app.
I wrote some capabilities for appium (Attachment below the post).
When I run the code in intellij idea, the simulator opens, app install begins and after it WebDrivetAgent install too.
Then, the app opens and closes 3 times, literally every second, and then it closes.
Anyone seen a case like this?
Attaching logs from the server
The test annotation just for check that the driver opens.
#Test
public void SetUp() throws MalformedURLException {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("platformName", "iOS");
cap.setCapability("platformVersion", "12.4");
cap.setCapability("deviceName", "iPhone 8 Plus");
cap.setCapability("app","/Users/mykll/Desktop/Payload/Leumi-Loyalty-MESIRA.app");
cap.setCapability("noReset", true);
cap.setCapability("fullReset",false);
driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"),cap);
}
There is some logs from appium:
[WD Proxy] Got an unexpected response: {"value":"Failed to launch com.leumi.leumiLoyalty application","sessionId":"4FAF5EAB-ABD2-4505-B01B-09E298A49B4C","status":13}
[MJSONWP] Matched JSONWP error code 13 to UnknownError
[XCUITest] Failed to create WDA session (An unknown server-side error occurred while processing the command. Original error: Failed to launch com.leumi.leumiLoyalty application). Retrying...
[BaseDriver] Event 'wdaSessionAttempted' logged at 1565026119270 (20:28:39 GMT+0300 (EEST))
[XCUITest] Sending createSession command to WDA
[WD Proxy] Matched '/session' to command name 'createSession'
[WD Proxy] Proxying [POST /session] to [POST http://localhost:8100/session] with body: {"desiredCapabilities":{"bundleId":"com.leumi.leumiLoyalty","arguments":[],"environment":{},"eventloopIdleDelaySec":0,"shouldWaitForQuiescence":true,"shouldUseTestManagerForVisibilityDetection":false,"maxTypingFrequency":60,"shouldUseSingletonTestManager":true}}

WDA Connection Time Out with Appium 1.10.0 & IOS (12.1.2)

Please , I need your help about one problem :
I obtain this message error with appium "WDA connection timeout" when I launched my tests automated from IPhone 6+ with version system (12.1.2) . I use XCode 10.1 and the WebDriverAgent is installed with success on my IPhone.I join you a part of logs Appium :
[XCUITest] Connection to WDA timed out
[iProxy] recv failed: Operation not permitted
[HTTP] --> POST /wd/hub/session/117cd327-7c9e-4888-971e-76b6c4c25237/timeouts
[HTTP] {"implicit":80000}
[W3C (117cd327)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,80000,"117cd327-7c9e-4888-971e-76b6c4c25237"]
[XCUITest] Executing command 'timeouts'
[BaseDriver] W3C timeout argument: {"implicit":80000}}
[BaseDriver] Set implicit wait to 80000ms
[W3C (117cd327)] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/117cd327-7c9e-4888-971e-76b6c4c25237/timeouts 200 3 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/117cd327-7c9e-4888-971e-76b6c4c25237/timeouts
[HTTP] {"implicit":300000}
[W3C (117cd327)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,300000,"117cd327-7c9e-4888-971e-76b6c4c25237"]
[XCUITest] Executing command 'timeouts'
[BaseDriver] W3C timeout argument: {"implicit":300000}}
[BaseDriver] Set implicit wait to 300000ms
[W3C (117cd327)] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/117cd327-7c9e-4888-971e-76b6c4c25237/timeouts 200 3 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/117cd327-7c9e-4888-971e-76b6c4c25237/touch/perform
[HTTP] {"actions":[{"action":"tap","options":{"x":220,"y":417}}]}
[W3C (117cd327)] Calling AppiumDriver.performTouch() with args: [[{"action":"tap","options":{"x":220,"y":417}}],"117cd327-7c9e-4888-971e-76b6c4c25237"]
and :
[XCUITest] WebDriverAgent information:
[XCUITest] {
[XCUITest] "state": "success",
[XCUITest] "os": {
[XCUITest] "name": "iOS",
[XCUITest] "version": "12.1.2"
[XCUITest] },
[XCUITest] "ios": {
[XCUITest] "simulatorVersion": "12.1.2",
[XCUITest] "ip": null
[XCUITest] },
[XCUITest] "build": {
[XCUITest] "time": "Jan 30 2019 12:28:16"
[XCUITest] }
Before, I haven't this problem because I used XCode 9.2 and appium 1.7 and version system ios (11.2.6).
I had read many answers for other problems that like the mine but I didn't find the solution.
Thank you very much in Advance,
Best Regards,

Appium - Timing out and Never got a response from command

We have UI tests to be started by Jenkins using Appium, but it results with an error:
remote stacktrace: UnknownError: An unknown server-side error occurred
while processing the command. Original error: Error getting AVD with
retry. Original error: Condition unmet after 60063 ms. Timing out.
And there is no emulator process found when Appium's task is running.
Also Appium's output says:
[debug] [ADB] Emulator Nexus_5X_API_26 not running
[debug] [ADB] Trying to find Nexus_5X_API_26 emulator
[debug] [ADB] Getting connected emulators
[debug] [ADB] Getting connected devices...
[debug] [ADB] 0 device(s) connected
[debug] [ADB] 0 emulator(s) connected
OK, I see that device wasn't started and this is cause for the "Timeout" error.
But why Appium can't start it?
I'm able to get the emulator executable, and Jenkin's job which is starting Appium's task can see the device:
[Pipeline] sh
+ avdmanager list avd
...
Name: Nexus_5X_API_26
Device: Nexus 5X (Google)
Path: /home/user/.android/avd/Nexus_5X_API_26.avd
Target: Google Play (Google Inc.)
Based on: Android 8.0 (Oreo) Tag/ABI: google_apis_playstore/x86
Skin: 1080x1920
Sdcard: 100 MB
---------
Name: test
Path: /home/user/.android/avd/test.avd
Target: Google APIs (Google Inc.)
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
[Pipeline] sh
+ emulator -list-avds
Nexus_5X_API_26
test
If I'm starting device manually just by running:
/android/Android/sdk/emulator/emulator -avd Nexus_5X_API_26
And trigger Jenkin's job after this - I have another error:
...
[ADB] Using adb from /android/Android/sdk/platform-tools/adb
[debug] [ADB] Trying to find Nexus_5X_API_26 emulator
[debug] [ADB] Getting connected emulators
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] 1 emulator(s) connected
[debug] [ADB] Sending telnet command to device: avd name
[debug] [ADB] Getting running emulator port
[debug] [ADB] Socket connection to device created
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1542807589908 (15:39:49 GMT+0200 (EET))
[debug] [W3C] Encountered internal error running command: Error: Error getting AVD. Original error: Never got a response from command
[debug] [W3C] at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:488:11)
...
Any ideas?
Can't even google anything with the "appium Never got a response from command" request...
Also, I'm not able to reproduce this issue on my workstation's laptop - all works just perfectly.
UPD Properties are:
<profile>
<id>linux-emulator-8.0</id>
<properties>
<hub.url>http://0.0.0.0:4723/wd/hub</hub.url>
<device.name>Android Emulator</device.name>
<avd>Nexus_5X_API_26</avd>
<platform.name>Android</platform.name>
<platform.version>8.0</platform.version>
<auto.grant.permissions>true</auto.grant.permissions>
<full.reset>true</full.reset>
<no.reset>false</no.reset>
<app.path>/home/user/project/project.apk</app.path>
<app.name>com.gen.workoutme</app.name>
<screenshot.path>
${project.basedir}/../screenShots/${platform.name}/${platform.version}/${device.name}/
</screenshot.path>
<automation.name>UiAutomator2</automation.name>
</properties>
</profile>
UPD 2 Not sure how - but not it works if run emulator manually.
But still, there is a problem with starting the emulator from Appium itself.
Found the weird error in its log:
[ADB] [AVD OUTPUT] Fatal: QXcbConnection: Could not connect to display ((null):0, (null))
[ADB] [AVD OUTPUT] INFO: QtLogger.cpp:66: Fatal: QXcbConnection: Could not connect to display ((null):0, (null))
[ADB] Emulator avd Nexus_5X_API_26 exited with code null, signal SIGABRT
Can't google for reason yet but it looks like the main issue - something with a connection to the $DISPLAY, although it present.
I am able to start and run tests on emulator without any problem. I use following three capabilities along with other capabilities while setting up the driver.
avd: Name of AVD
avdLaunchTimeout: Time out to wait for emulator to launch.
avdReadyTimeout: Time out to wait for emulator to get ready.
Try using these capabilities and you should be good.
Also check if there is any updates for Android SDK and emulator. If there is update available, it's good idea to update it.
Settings or python:
options = UiAutomator2Options()
options.avd = 'YOUR_AVD_NAME'
# Timeout to wait until Android Emulator is started in milliseconds
options.avd_launch_timeout = 25 * 1000
# Timeout to wait until Android Emulator is fully booted and is ready for usage in milliseconds
options.avd_ready_timeout = 20 * 1000
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', options=options)

Appium: Waiting for elements on iOS doesn't work anymore

I'm automizing tests for Android and iOS. Lately (probably after I've updated to appium 1.9.1 and java-client 6.1.0) I have issues with the iOS tests.
Many tests fail, because WebElements couldn't be found. I'm using WebDriverWait to find elements like in this example:
private WebElement getWebElement(By by, int timeOutInSeconds) {
return (new WebDriverWait(appiumDriver, timeOutInSeconds)).until(ExpectedConditions.presenceOfElementLocated(by));
}
The tests don't wait to find the element anymore. Instead an exception is thrown immediately.
I'm using XCUITest for iOS and uiautomator2 on android. On android the tests are still fine.
Edit (2018-10-29 18:33):
It feels like page factory is reporting the element is there, then randomElement.isDisplayed() will be executed on the element which throws directly an error, because it can't find the element.
And another observation:
In some cases the waiting duration works properly on iOS, but I couldn't find a pattern yet.
Edit (2018-12-14 15:56):
Still no solution found. Note: My tests make screenshots on failure. I can see on a lot of screenshots, the elements that caused the failure. The logs say they couldn't be found, but I can clearly see them on the screen. Makes no sense. Hoping for ideas!
Edit (2019-01-11 15:05):
In the logs, it looks like the element is found (response 200), but when I want to perform a click, it says it's 'not visible on the screen an thus not interactable'.
...
[HTTP] --> POST /wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/element
[HTTP] {"using":"id","value":"myapp"}
[debug] [W3C] Calling AppiumDriver.findElement() with args: ["id","buttonNext","59e9ace4-55a5-4b07-ad0e-af874dc42a6d"]
[debug] [XCUITest] Executing command 'findElement'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [JSONWP Proxy] Matched '/element' to command name 'findElement'
[debug] [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/CE691ADA-FC54-48AE-9AA0-1DA6212DB2CC/element] with body: {"using":"id","value":"buttonNext"}
[debug] [JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"24010000-0000-0000-0308-000000000000"},"sessionId":"CE691ADA-FC54-48AE-9AA0-1DA6212DB2CC","status":0}
[debug] [W3C] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"24010000-0000-0000-0308-000000000000"}
[HTTP] <-- POST /wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/element 200 180 ms - 88
[HTTP]
[HTTP] --> POST /wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/element/24010000-0000-0000-0308-000000000000/click
[HTTP] {"id":"24010000-0000-0000-0308-000000000000"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[debug] [XCUITest] Executing command 'proxyReqRes'
[debug] [JSONWP Proxy] Matched '/wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/element/24010000-0000-0000-0308-000000000000/click' to command name 'click'
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/element/24010000-0000-0000-0308-000000000000/click] to [POST http://localhost:8100/session/CE691ADA-FC54-48AE-9AA0-1DA6212DB2CC/element/24010000-0000-0000-0308-000000000000/click] with body: {"id":"24010000-0000-0000-0308-000000000000"}
[debug] [JSONWP Proxy] Got response with status 200: {"value":"Error Domain=com.facebook.WebDriverAgent Code=1 \"The element '\"buttonNext\" Button' is not visible on the screen and thus is not interactable\" UserInfo={NSLocalizedDescription=The element '\"buttonNext\" Button' is not visible on the screen and thus is not interactable}","sessionId":"CE691ADA-FC54-48AE-9AA0-1DA6212DB2CC","status":13}
[debug] [W3C] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: The request to /wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/element/24010000-0000-0000-0308-000000000000/click has failed
[debug] [W3C] at JWProxy.proxy$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:182:13)
[debug] [W3C] at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[debug] [W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[debug] [W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[debug] [W3C] at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[HTTP] <-- POST /wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/element/24010000-0000-0000-0308-000000000000/click 500 4875 ms - 1779
[HTTP]
[HTTP] --> GET /wd/hub/session/59e9ace4-55a5-4b07-ad0e-af874dc42a6d/screenshot
[HTTP] {}
...

Iphone 5 Appium and jUnit - App did not have elements

I have a problem with my automated tests on iPhone 5. I could previously start test on iPad with iOS 6.1 but now I would like to do it on iPhone 5 iOS 8.1
In eclipse I got message A new session could not be created.
Log from appium:
error: Failed to start an Appium session, err was: Error: App did not have elements
info: [debug] Error: App did not have elements
at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ ios.js:459:30
at Object.cb [as callback] (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios /ios-controller.js:247:7)
at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:801:43)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:32:16
at exports.respond (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js:28:9)
at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios.js:1449:18)
at getResultAndSendNext (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/lib/command-proxy.js:146:20)
at Socket.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/lib/command-proxy.js:88:7)
at Socket.emit (events.js:117:20)
at _stream_readable.js:944:16
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: App did not have elements)","origValue":"App did not have elements"},"sessionId":null}
info: <-- POST /wd/hub/session 500 29025.843 ms - 172
capabilities:
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.1");
capabilities.setCapability("deviceName", "iPhone 5 iOS 8.1");
capabilities.setCapability("udid","104ce995950282f9dfaf371bf05ee6b00e7c0027);
Can anybody help me?
Beginning iOS 8, excessive amount of NSLog outputs can create deadlock in the internal communication of UIAutomation and Appium server. (read this article for more info Appium's Github page)
This causes such undesired outcomes.
A preventive workaround is described HERE: which solved the issue on my case. I hope it will help.

Resources