Appium returns visible: "false" for isDisplayed() to an element that is found by appium

Hi,

I’m running into an issue when running my test on real device iOs (8.1.1) against appium server 1.3.1/1.3.3, certain elements that are present on a screen (being in focus) are not seen by isDisplayed().

Details:

  • All elements under test have accessibility labels and the following attributes:
    enabled: true
    visible: false
    valid: true

  • Elements that are not visible to isDisplayed() during test run-time, are visible in Appium Inspector but not visible when switching Show Invisible OFF) and are found by appium server during runtime (see log below).

Questions:

  • How exactly does isDisplayed() work in such situation?
  • What differentiates visibility of elements to isDisplayed() when both: visible and not visible have similar element attributes values? For ex., elements that are visible to isDisplayed() during test runtime have the following attributes:
    enabled: true
    visible: false
    valid: true

Elements that are not visible to isDisplayed() during runtime have the following attributes:
enabled: true
visible: false
valid: true

Appium server log:
//I’m looking for presence of a button called “Choose”

info: [debug] Pushing command to appium work queue: “au.getElementByName(‘Choose’)”
info: [debug] Sending command to instruments: au.getElementByName(‘Choose’)
info: [debug] [INST] 2014-11-20 22:25:38 +0000 Debug: evaluation finished
info: [debug] [INST] 2014-11-20 22:25:38 +0000 Debug: responding with:
info: [debug] [INST] 2014-11-20 22:25:38 +0000 Debug: Running system command #144: /Users/bzayats/local/bin/node /Users/Bzayats/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:""}…
info: [debug] [INST] 2014-11-20 22:25:39 +0000 Debug: Got new command 144 from instruments: au.getElementByName(‘Choose’)
info: [debug] [INST] 2014-11-20 22:25:39 +0000 Debug: evaluating au.getElementByName(‘Choose’)
info: [debug] [INST] 2014-11-20 22:25:39 +0000 Debug: evaluation finished
info: [debug] [INST] 2014-11-20 22:25:39 +0000 Debug: Lookup returned [object UIAButton] with the name “Choose” (id: 421).
info: [debug] Socket data received (40 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“421”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“421”},“sessionId”:“e26cbb9a-e1e2-4c9f-9741-3e04a5f8c88a”}
info: <-- POST /wd/hub/session/e26cbb9a-e1e2-4c9f-9741-3e04a5f8c88a/element 200 1252.859 ms - 89 {“status”:0,“value”:{“ELEMENT”:“421”},“sessionId”:“e26cbb9a-e1e2-4c9f-9741-3e04a5f8c88a”}
info: --> GET /wd/hub/session/e26cbb9a-e1e2-4c9f-9741-3e04a5f8c88a/element/421/displayed {}
info: [debug] Pushing command to appium work queue: “au.getElement(‘421’).isDisplayed()”
info: [debug] Sending command to instruments: au.getElement(‘421’).isDisplayed()
info: [debug] [INST] 2014-11-20 22:25:39 +0000 Debug: responding with:
info: [debug] [INST] 2014-11-20 22:25:39 +0000 Debug: Running system command #145: /Users/bzayats/local/bin/node /Users/Bzayats/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“421”}}…
info: [debug] [INST] 2014-11-20 22:25:40 +0000 Debug: Got new command 145 from instruments: au.getElement(‘421’).isDisplayed()
info: [debug] [INST] 2014-11-20 22:25:40 +0000 Debug: evaluating au.getElement(‘421’).isDisplayed()
info: [debug] Socket data received (28 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:false}
info: [debug] Responding to client with success: {“status”:0,“value”:false,“sessionId”:“e26cbb9a-e1e2-4c9f-9741-3e04a5f8c88a”}
info: <-- GET /wd/hub/session/e26cbb9a-e1e2-4c9f-9741-3e04a5f8c88a/element/421/displayed 200 1089.151 ms - 77 {“status”:0,“value”:false,“sessionId”:“e26cbb9a-e1e2-4c9f-9741-3e04a5f8c88a”}

Can you post this on the GitHub site? for the dev team to take a look at? https://github.com/appium/appium/issues

Will do. Thanks for recommendation.

@JackLondon Just had a thought. What happens if you loop like this

// pseudo code; add a time out if you want
while (!driver.isDisplayed()) ;
printf("It's visible!");

I’m wondering if you’re hitting a race condition of some kind. Depending on your client, you may also have a waitForElement function that you can try.

Is there any way you share your app with me so I can debug? I’m on the Appium team, [email protected]. We’ll use it internally for testing only and will not share it with anyone.

@0x1mason

Not sure if I’ll be able to share the app (not released yet), but I’m talking to devs/management right now to see what can be done there. Regarding the loop idea - I’ve used the waitUntilElementToBeClickable(appPom.getChooseButton()); //which basically waits for the Choose button to be clickable. However, server would fail there since that button would never be returned as a WebElement to the calling method.

@0x1mason
I’ve put a timeout for 10 and 20 sec, and no difference - isDisplayed() still fails to see the element. Once again, the elements I’m trying to get to are not visible by appium’s inspector if to switch “Show Invisible” OFF. I just don’t understand which attribute “Show Invisible” is relying upon to see the elements as visible.

Out of curiosity, I’ve performed same test with isEnabled() instead of isDisplayed(), and got a positivie result:

info: [debug] Pushing command to appium work queue: “au.getElementByName(‘Choose’)”
info: [debug] Sending command to instruments: au.getElementByName(‘Choose’)
info: [debug] [INST] 2014-11-24 22:37:16 +0000 Debug: Got new command 145 from instruments: au.getElementByName(‘Choose’)
info: [debug] [INST] 2014-11-24 22:37:16 +0000 Debug: evaluating au.getElementByName(‘Choose’)
info: [debug] [INST] 2014-11-24 22:37:16 +0000 Debug: evaluation finished
info: [debug] [INST] 2014-11-24 22:37:16 +0000 Debug: Lookup returned [object UIAButton] with the name “Choose” (id: 421).
info: [debug] Socket data received (40 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“421”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“421”},“sessionId”:“079a58c3-e36e-402a-a1ab-1d2b15185ff0”}
info: <-- POST /wd/hub/session/079a58c3-e36e-402a-a1ab-1d2b15185ff0/element 200 1422.958 ms - 89 {“status”:0,“value”:{“ELEMENT”:“421”},“sessionId”:“079a58c3-e36e-402a-a1ab-1d2b15185ff0”}
info: --> GET /wd/hub/session/079a58c3-e36e-402a-a1ab-1d2b15185ff0/element/421/enabled {}
info: [debug] Pushing command to appium work queue: “au.getElement(‘421’).isEnabled() === 1”
info: [debug] Sending command to instruments: au.getElement(‘421’).isEnabled() === 1
info: [debug] [INST] 2014-11-24 22:37:16 +0000 Debug: responding with:
info: [debug] [INST] 2014-11-24 22:37:16 +0000 Debug: Running system command #146: /Users/bzayats/local/bin/node /Users/Bzayats/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“421”}}…
info: [debug] [INST] 2014-11-24 22:37:17 +0000 Debug: Got new command 146 from instruments: au.getElement(‘421’).isEnabled() === 1
info: [debug] [INST] 2014-11-24 22:37:17 +0000 Debug: evaluating au.getElement(‘421’).isEnabled() === 1
info: [debug] Socket data received (27 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:true}

I am having similar issue on our app as well.
elementId 24 could not be tapped I get this error intermittently for all clickable elements. Elements are visible and clickable but still fails.

I am using appium 1.3.6 with latest ruby lib.

I have an issue with iOS like when need to toggle a button which is not visible on UI .When I try to toggle the button using X-path then element hierarchy is getting changed but the button is not getting toggled , cursor is moving to the button
I tried with appium(1.3.1,1.3.7) which throws same problem
can anyone help me out on this
How can I increase the speed of executing the test-cases because X-path is behaving very slow
Do we have any other methods to access elements in iOS.
@dmenezes

@Venkat_Reddy

What xpath are you using for the button?
Have you tried finding the element by name? Or classname?

Thanks for reply @dmenezes

Xpath :

driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[8]/UIAButton[1]").click()

Classname:
table = driver.find_element_by_class_name(“UIATableView”)
self._row = table.find_elements_by_class_name(“UIATableCell”)[index]
self._row.click()
I tried above one but it throws exception as driver does not support indexes

Do we have any method to refresh app ?

“//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[8]/UIAButton[1]” change this to
//UIATableCell[8]/UIAButton[1] OR //UIAButton[1]

also try this:
button_name = driver.find_element_by_xpath("//UIATableCell[8]/UIAButton[1]")
button_name.click()

I will look more into classname and let you know.

I am not sure of ways to refresh an app.

Hi! May be you can help me with this issue: how can i check element is present in my tests if it has false for “visible”?

this might help
https://developer.apple.com/documentation/objectivec/nsobject/1615141-isaccessibilityelement

I also stuck with same issue button is clickable manually but if I tried to automate it is not clickable because it is clickable=‘false’
Any help or suggestion?

try to get the point of the element and click the point.

Hi

I am facing same issue where i am using appium 1.7 and Xcode 9.3,
when i am trying to inspect element its showing its visible property as false, Please let me know how i can fix it as its a blocker

1 Like

I’m having this same issue using Xcode 9.3 and Appium 1.7.2. It seems one of the HUDs in the app I’m working on never becomes visible. This is also a blocker for me. Does anyone know of a workaround?

Edit: I’ve moved back to Xcode 9.2 and my tests seem to run successfully again.

1 Like

I’m using Appium with BrowserStack-Windows-I cannot perform send keys. it has the property as visible false

I applied click but it never takes.