Java-client: Appium, Java, iOSDriver: Can't get "visible" attribute from element

Created on 28 Jul 2016  路  12Comments  路  Source: appium/java-client

Description

Trying to define if element is visible or not on screen in the current moment of time.
Sometimes it's possible that element is represented in tree so isDisplayed(); returns "true" but element is hidden under views.

The only way to find if element actually visible it's to get "visible" attribute. But when I try to get it "UIAElements don't have the attribute '+visible'" error returned.

Environment

  • java 1.8.0_25
  • Appium Version 1.5.3 (Ara)
  • Mac OSX 10.11.05
  • Node.js v4.4.4
  • iOS Simmulator iPad Air 2 iOS 9.3.

    Code To Reproduce Issue [ Good To Have ]

public static IOSDriver driver;
System.out.println("DDDDD " + driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAButton[2])").getAttribute(" visible"));

Link to Appium logs

Appium server stopped.

org.openqa.selenium.UnsupportedCommandException: UIAElements don't have the attribute '+visible' (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'Bogdans-MacBook-Air.local', ip: '192.168.88.66', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.5', java.version: '1.8.0_25'
Driver info: Common.PlatformPreferences$2
Capabilities [{app=/Users/Bohdan/Downloads/Marc-O-Polo-MerchantBETA.ipa, networkConnectionEnabled=false, noReset=true, language=de, databaseEnabled=false, locale=de_DE, deviceName=iPadAir, platform=MAC, desired={app=/Users/Bohdan/Downloads/Marc-O-Polo-MerchantBETA.ipa, noReset=true, sendKeyStrategy=setValue, platformVersion=9.3, language=de, platformName=iOS, locale=de_DE, deviceName=iPadAir, autoAcceptAlerts=true}, sendKeyStrategy=setValue, platformVersion=9.3, webStorageEnabled=false, locationContextEnabled=false, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS, autoAcceptAlerts=true}]
Session ID: bbc1ad32-79e0-4d1e-9fce-8b80283281fb
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:27)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:269)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:27)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.execute(IOSElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.getAttribute(RemoteWebElement.java:123)
at Tests.CustomerSelection.customerSelectionTest(CustomerSelection.java:56)
at Common.TestActions.main(TestActions.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

bug server side

All 12 comments

@Bohdan1304 You should get the visiblity by element.isDisplayed()

7riun

@SrinivasanTarget Yes, you're right, I tried.

But isDisplayed() returns true, while element is not on front. Only thing changes when element became not on front is "visible" attribute.

Like this:
<UIAImage name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/0/7" x="71.0000302045703" y="27.00000310350866" width="50.00000218556954" height="50.00000218556947">

For me this sounds like a bug , in selenium + web I've used getAttribute method many a times. Ideally it should be supported in appium world as well.

IMO this ticket needs to be re-opened and prioritized.

@Bohdan1304 @vikramvi If isDisplayed() returns true it is most likely an instruments bug.I have seen related issues in server already. If you wanted to create one, you can but in server as client cannot determine the element visibility. You can check this alternatives: http://stackoverflow.com/questions/15088832/getattribute-not-returning-complete-value-for-style-in-selenium

@Bohdan1304 @vikramvi Coming to getAttribute seems like a good idea. But i need @imurchie @TikhomirovSergey thoughts on this.

@SrinivasanTarget Thank for link to server. Will check alternatives, but also would be good to have some solution.

@Bohdan1304 @vikramvi @SrinivasanTarget
It is not the bug of the java client.

There was the similar issie
https://github.com/appium/java-client/issues/355

@Bohdan1304 Can you raise this in server side? This should go into features milestone in server

@SrinivasanTarget Yes, sure. Do you mean https://github.com/appium/appium-uiautomator2-server ?

@Bohdan1304 Please raise here: https://github.com/appium/appium/issues/

This issue was moved to appium/appium#6717

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chandan188 picture chandan188  路  3Comments

telangn picture telangn  路  7Comments

vrunoa picture vrunoa  路  5Comments

ryltar picture ryltar  路  9Comments

Zaakupendrak picture Zaakupendrak  路  9Comments