Anyone faced this issue "Unable to find out 'bounds' value using getAttribute method" in android appium

Hi All,

I am verifying a scenario where I need to get the size of text. I use UI Automator Viewer to find the element and get that there is “bounds” attribute which contains the size of the text. Please see the below image.

such as: bounds => [20,214][748,708]

I used following code: driver.findElement(By.id(“com.et.reader.activities:id/story_headling”)).getAttribute(“bounds”);

But I am not able to find out attribute. Please refer the appium log:

info: [debug] [BOOTSTRAP] [debug] Finding com.et.reader.activities:id/story_headling using ID with the contextId: multiple: false

info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.et.reader.activities:id/story_headling]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“5”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“5”},“sessionId”:“04144063-6fff-4374-b6ec-34f8b9fd8868”}
info: ← POST /wd/hub/session/04144063-6fff-4374-b6ec-34f8b9fd8868/element 200 694.371 ms - 87 {“status”:0,“value”:{“ELEMENT”:“5”},“sessionId”:“04144063-6fff-4374-b6ec-34f8b9fd8868”}
info: → GET /wd/hub/session/04144063-6fff-4374-b6ec-34f8b9fd8868/element/5/attribute/bounds {}
info: [debug] Pushing command to appium work queue: [“element:getAttribute”,{“elementId”:“5”,“attribute”:“bounds”}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getAttribute”,“params”:{“elementId”:“5”,“attribute”:“bounds”}}
info: [debug] Responding to client with error: {“status”:7,“value”:{“message”:“An element could not be located on the page using the given search parameters.”,“origValue”:“This element does not have the ‘bounds’ attribute”},“sessionId”:“04144063-6fff-4374-b6ec-34f8b9fd8868”}
info: ← GET /wd/hub/session/04144063-6fff-4374-b6ec-34f8b9fd8868/element/5/attribute/bounds 500 9.170 ms - 228
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getAttribute
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:7,“value”:“This element does not have the ‘bounds’ attribute”}
info: → DELETE /wd/hub/session/04144063-6fff-4374-b6ec-34f8b9fd8868 {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: F:\android-sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell “input keyevent 3”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 7.829
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“04144063-6fff-4374-b6ec-34f8b9fd8868”}
info: ← DELETE /wd/hub/session/04144063-6fff-4374-b6ec-34f8b9fd8868 200 565.897 ms - 76 {“status”:0,“value”:null,“sessionId”:“04144063-6fff-4374-b6ec-34f8b9fd8868”}

Console Log:

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds
For documentation on this error, please visit: Selenium
Please help me out if anyone have any idea!!

Thanks in Advance !!

You can get bounds like this

Webelement.getLocation().getX();
Webelement.getLocation().getY();

I think it does connected to new method for WebElement.

/**

  • @return The location and size of the rendered element
    */
    Rectangle getRect();