Unable to capture objects : Web Driver Exception


#1

I am using Katalon V5.6.3

Appium Version 1.7.2
Android SDK: 28.0.2

Able to Connect the device; before splash screen i am getting “Unable to capture objects : Web Driver Exception”. below are the message that i am getting in details:

"An unknown server-side error occurred while processing the command. Original error: Cannot get screenshot data because of ‘The size of the taken screenshot equals to zero.’. Make sure the ‘LayoutParams.FLAG_SECURE’ is not set for the current view (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds

Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’

System info: host: ‘WINJITLAPTOP96’, ip: ‘192.168.0.176’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_181’

Driver info: com.kms.katalon.core.appium.driver.SwipeableAndroidDriver

Capabilities {app: C:\Users\deepakv\Downloads\…, autoGrantPermissions: true, automationName: uiautomator2, deviceName: motorola XT1635-02 (Android…, fullReset: false, javascriptEnabled: true, newCommandTimeout: 1800, noReset: true, platform: ANDROID, platformName: ANDROID, udid: ZY223PWMFH}

Session ID: 4b52200c-7735-472f-9d55-8149a5444459"

Also below is the log file for same:

[Appium] Welcome to Appium v1.7.2 (REV bade6dc09ad45a6e3db08819a7fe0f047b572e01)

[Appium] Non-default server args:

[Appium] port: 42872

[Appium] loglevel: info

[Appium] chromeDriverPort: 42873

[Appium] tmpDir: C:\Users\deepakv\AppData\Local\Temp\\Katalon\Appium\Temp1536067959023

[Appium] Appium REST http interface listener started on 0.0.0.0:42872

[HTTP] --> GET /wd/hub/status {}

[HTTP] <-- GET /wd/hub/status 200 113 ms - 110

[HTTP] --> GET /wd/hub/status {}

[HTTP] <-- GET /wd/hub/status 200 105 ms - 110

[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“app”:“C:\\Users\\deepakv\\Downloads\\DCB_V1.0.0.6.apk”,“autoGrantPermissions”:true,“automationName”:“uiautomator2”,“deviceName”:“motorola XT1635-02 (Android 8.0.0)”,“fullReset”:false,“newCommandTimeout”:1800,“noReset”:true,“platform”:“ANDROID”,“platformName”:“Android”,“udid”:“ZY223PWMFH”},“capabilities”:{“desiredCapabilities”:{“app”:“C:\\Users\\deepakv\\Downloads\\DCB_V1.0.0.6.apk”,“autoGrantPermissions”:true,“automationName”:“uiautomator2”,“deviceName”:“motorola XT1635-02 (Android 8.0.0)”,“fullReset”:false,“newCommandTimeout”:1800,“noReset”:true,“platform”:“ANDROID”,“platformName”:“Android”,“udid”:“ZY223PWMFH”},“firstMatch”:[{“platformName”:“android”}]}}

[Appium] Merged W3C capabilities {“desiredCapabilities”:{“app”:"C:\\Users\\deepa… into desiredCapabilities object {“app”:"C:\\Users\\deepakv\\Downloads\\DCB_V1.0…

[Appium] Creating new AndroidUiautomator2Driver (v0.11.0) session

[Appium] Capabilities:

[Appium] app: C:\Users\deepakv\Downloads\DCB_V1.0.0.6.apk

[Appium] autoGrantPermissions: true

[Appium] automationName: uiautomator2

[Appium] deviceName: motorola XT1635-02 (Android 8.0.0)

[Appium] fullReset: false

[Appium] newCommandTimeout: 1800

[Appium] noReset: true

[Appium] platform: ANDROID

[Appium] platformName: android

[Appium] udid: ZY223PWMFH

[BaseDriver] The following capabilities were provided, but are not recognized by appium: platform.

[BaseDriver] Session created with session id: 4b52200c-7735-472f-9d55-8149a5444459

[BaseDriver] Using local app ‘C:\Users\deepakv\Downloads\DCB_V1.0.0.6.apk’

[AndroidDriver] Java version is: 1.8.0_181

[ADB] Checking whether adb is present

[ADB] Using adb.exe from C:\Users\deepakv\.katalon\tools\android_sdk\platform-tools\adb.exe

[AndroidDriver] Retrieving device list

[AndroidDriver] Using device: ZY223PWMFH

[ADB] Checking whether adb is present

[ADB] Checking whether aapt is present

[ADB] Using aapt.exe from C:\Users\deepakv\.katalon\tools\android_sdk\build-tools\28.0.2\aapt.exe

[ADB] Extracting package and launch activity from manifest

[ADB] Getting device platform version

[ADB] Checking whether aapt is present

[AndroidDriver] setDeviceLanguageCountry requires language or country.

[AndroidDriver] Got language: ‘null’ and country: ‘null’

[ADB] Checking whether aapt is present

[ADB] Checking whether aapt is present

[AndroidDriver] Using app unlock, this is going to be deprecated!

[AndroidDriver] Unlocking screen

[ADB] Using apksigner.bat from C:\Users\deepakv\.katalon\tools\android_sdk\build-tools\28.0.2\apksigner.bat

[AndroidDriver] Remote apk path is /data/local/tmp/e009338eb7e73ab8b7832ec838cdf75e.apk

[ADB] Checking whether aapt is present

[ADB] Extracting package and launch activity from manifest

[ADB] com.dcb contains no permissions available for granting.

[UiAutomator2] Starting uiautomator2 server v0.3.0

[UiAutomator2] Running command: ‘adb -s ZY223PWMFH shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner’

[UiAutomator2] Waiting up to 20000ms for UiAutomator2 to be online…

[UiAutomator2] UiAutomator2 did not start the activity we were waiting for, ‘com.dcb/com.dcb.prelogin.splash.activity.SplashActivity’. Starting it ourselves

[Appium] New AndroidUiautomator2Driver session created successfully, session 4b52200c-7735-472f-9d55-8149a5444459 added to master session list

[HTTP] <-- POST /wd/hub/session 200 95558 ms - 363

[HTTP] --> GET /wd/hub/status {}

[HTTP] <-- GET /wd/hub/status 200 114 ms - 121

[HTTP] --> POST /wd/hub/session/4b52200c-7735-472f-9d55-8149a5444459/timeouts {“type”:“implicit”,“ms”:60000}

[HTTP] <-- POST /wd/hub/session/4b52200c-7735-472f-9d55-8149a5444459/timeouts 200 11 ms - 76

[HTTP] --> GET /wd/hub/session/4b52200c-7735-472f-9d55-8149a5444459/source {}

[MJSONWP] Driver proxy active, passing request on via HTTP proxy

[JSONWP Proxy] Replacing sessionId ee44f340-bf10-4753-9ca6-15ca3f45d005 with 4b52200c-7735-472f-9d55-8149a5444459

[HTTP] <-- GET /wd/hub/session/4b52200c-7735-472f-9d55-8149a5444459/source 200 3147 ms - 20515

[HTTP] --> GET /wd/hub/session/4b52200c-7735-472f-9d55-8149a5444459/screenshot {}

[AndroidDriver] Cannot get screenshot data with ‘adb exec-out’ because of ‘Screenshot returned no data’. Defaulting to ‘adb shell’ call

[HTTP] <-- GET /wd/hub/session/4b52200c-7735-472f-9d55-8149a5444459/screenshot 500 745 ms - 333


#2

Hi @deepak_verma,

Following up on this issue. The error you’re seeing:

Cannot get screenshot data because of ‘The size of the taken screenshot equals to zero.’. Make sure the ‘LayoutParams.FLAG_SECURE’ is not set for the current view

Is because Android allows developers to mark certain screens as “secure” so that they can’t have screenshots taken of them. This is usually done for login, credit card, or other sensitive data screens. Because the Katalon Studio Test Recorder and Mobile Spy work off of screenshots, you’ll get this error.

Capturing of the test objects should still work, however, you just won’t be able to see the screenshot to get a preview of the screen element you’re selecting.

Hope this helps,

Chris


#3

@Chris_Trevarthen Are you sure you should be able to capture test objects even when a TakeScreenshotException occurs?

With Katalon Studio 6.x this is not possible. I get a TakeScreenshotException but no test object capture. How should I capture test objects in an Android screen which is probably secured using the secure flag?


#4

Hi @mdmmzm,

I’m currently using Katalon Studio 6.0.5 with Appium 1.8.2-beta (this is for iOS 12 support, so if you’re only testing Android, Appium 1.8.1 should work).

When I try to use the Spy Mobile on a screen that is marked as secure, I get the error message below. Clicking the “Details” button shows that the screen is probably secure:

If you click “OK”, the error dialog goes away.

You won’t be able to see the preview of the screen in the Device View window, but you can still capture objects in the Mobile Object Spy window. You’ll need to rely on the name/label of the object to be able to know what you’re capturing, but you will still be able to capture the object by clicking the checkbox to the left of it.

Hope this helps,

Chris


About payment process
#5

@Chris_Trevarthen

Thank you. This helps for capturing the test objects.

Now I have a problem setting a value on the captured testobjects. Type of objects when captured is “ImageView”. It is not possible to execute “setText” or “sendKeys” on this type of objects. Even after “tapping” on it I cannot set text. Usually you can only set value on an input object like EditText. But this ImageView seems not to transform into an input object after tapping it.

How can I set the value on a testobject on a secure page?

PS: it is not possible to unset the “secure” flag because it is an external closed-source app.

Captured objects of type ImageView:
49

The secret page with pin input (6 seperate fields)


#6

Hi @mdmmzm,

Thanks for the screenshot and explanation, that’s helpful. You’re correct that you can only set text on text fields, and not images.

I’m thinking that if we can get the keyboard to come up at least, we can access the keys. When you are using the app normally (not testing) how do you get the keyboard to come up so that you can enter the PIN? Do you have to tap one of the circles first? I think we can make the test do the same thing.

Once the keyboard is up, you could try pressing the keys on the keypad like this post mentions:

Hope this helps,

Chris


#7

Hi @Chris_Trevarthen ,
Yes this works! Thank you.
A standard keyword would be helpful for typing via keyboard as you are gonna need it more than one time.


#8

Hi @Chris_Trevarthen

I have created a Gist for this purpose: Keyboard.groovy: Fill out numbers using Android Keyboard