UIAutomatorViewer is a tool to inspect and identify UI elements in Android apps. However not every UI element you see is accessible to UIAutomatorViewer. Sigh. I know. That sucks. But at the very least, UIAutomatorViewer lets you know which of these elements are not accessible.
I was messing around with Appium and DroidFish secretly hoping to write an automated test that would play out a famous chess game. I noticed that I was able to identify the chessboard but not the individual squares. Most parts of the app were identifiable using UIAutomatorViewer. For example, the buttons are easily identifiable in the UIAutomatorViewer as shown in the image below:
The chess board however is slightly different. In the UIAutomatorViewer you can see that NAF is set to true in the Node Details.
What is NAF ?
NAF means Not Accessible to Framework and only limited information may be available for these components. So if you want to automate a workflow involving a NAF element – well, good luck! I hope you have good relations with the developer and can request them to make a change to the application.
As a workaround, I decided to move the chess pieces by using the co-ordinates. This is not recommended. The co-ordinates will change for each device you test on. Do not use this approach unless you have no other option.
To assert that the correct move is played, I used the moveList – which thankfully is not NAF.
NOTE: I have reported the same on appium-discuss with the hopes that there is a better solution.
My journey as a tester started at Sun Microsystems (now Oracle). I was part of the testing and sustaining team for the Portal Server and Identity Management products. My first assignment was to test the Rewriter module. I enjoyed understanding the big picture, writing test cases, finding bugs and sometimes suggesting the fix too! I was hooked onto testing. Testing felt natural and intuitive to me. I am technically inclined and can write automation in Java, C++, Perl and Python. I am well versed with SilkTest, Selenium, Appium and Selendroid. I am a Computer Science graduate from BITS-Pilani. I love travelling and listening to music.
Hi,
I am using ‘UI Automator Viewer’ to build locators for my elements. But strangely, while capturing the screen of the Android emulator, all I get on the left side is a black screen. The app I am working on is a hybrid app and I am unable to figure out how to locate elements. Please help.
Thank You.
Richa, I’m not sure if we can help directly without seeing the app. It may just be that the element you want is not accessible to the framework. A couple of quick and generic checks: Which version of Android are you using in your emulator? Do you have access to either the app source code or access to the development team?
Hi Team,
Recently I have been assigned to working Appium automated solution for Native App which runs on Android and IOS. On my extensive research and exploration , I found your blog is one of the best blogs. Thanks for this to putting forward.
I have one doubt which is corresponding to my work , I am using all latest Appium components for automation. Appiumdriver statements are executing find in Android devices but not running in Emulator which is perfectly configured and app is installed through code. Below error I am seeing , can you guide me in this.
[debug] [BOOTSTRAP] [debug] Command returned error:java.lang.RuntimeException: Failed to Dump Window Hierarchy
[36minfo[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:”Failed to Dump Window Hierarchy”,”status”:13}
Exception in thread “main” org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Regards,
Kiran
Kiran, I’m glad you found our posts useful. We invest significant amount of time in writing up tutorials in the hope that it helps other testers.
Regarding the error, can you post the entire stack trace. Also let us know which version of Android the emulator image is using. In addition, can you tell us when the error happens? E.g.: Does it happen as soon as you execute your test? Or does the app launch and then while trying to perform something, you see this message? Or perhaps you expected the app to launch but you see just the home screen on the emulator?
Hi mam,
I have an issue :- When I enter passowrd in emulator using appium,eclipse, emulator keyboard space button get clicked. How to stop this space click.
Sunil,
Are you using co-ordinates to enter the password or using send_keys?
The co-ordinates vary for each emulator.
Hi Virushali,
I am a beginner in appium automtion tool ,i am basically a manual tester in games, right now i am trying to automate facebook status posting in android phone
My script runs sucessfully upto login to facebook and shows the facebook dahsboard, but it gets failed in locating the ‘Status’ button on facebook,your help will be appreciated .
Here is my script:-
package com.appium.facebook.androiduiselector;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
public class FacebookLoginTest {
@Test
public void testLoginFB() throws MalformedURLException, InterruptedException
{
DesiredCapabilities capabilities = new DesiredCapabilities() ;
capabilities.setCapability(“automationName”,”Appium”);
capabilities.setCapability(“platformnName”,”Android”);
capabilities.setCapability(“platformVersion”,”5.1.1″);
capabilities.setCapability(“deviceName”,”Nexus 6″ );
capabilities.setCapability(“app”,”C:\\Users\\Jenny\\Downloads\\facebook.apk”);
capabilities.setCapability(“appPackage”,”com.facebook.katana”);
capabilities.setCapability(“appActivity”, “com.facebook.katana.LoginActivity”);
AndroidDriver driver = new AndroidDriver (new URL (“http://127.0.0.1:4723/wd/hub”), capabilities) ;
driver.manage().timeouts().implicitlyWait(120,TimeUnit.SECONDS);
//automating login procedure to FB
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/login_username\”)”).sendKeys(“[email protected]”);
driver.sendKeyEvent(AndroidKeyCode.ENTER);
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/login_password\”)”).click();
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/login_password\”)”).sendKeys(“XXXX”);
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/login_login\”).text(\”LOG IN\”)”).click();
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/dbl_on\”).text(\”OK\”)”).click();
//Script fails here at below line
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/feed_composer_status_button\”).text(\”STATUS\”)”).click();
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/status_text\”)”).click();
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/status_text\”).text(\”What’s on your mind?\”)”).sendKeys(“hello”);
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(\”com.facebook.katana:id/composer_primary_named_button\”).description(\”Post\”)”).click();
Thread.sleep(8000);
}
}
Jennifer,
Tried the FB status button click and the following is working for me:
status_icon = self.driver.find_element_by_id(‘com.facebook.katana:id/feed_composer_status_button’)
status_icon.click()
You can try giving a wait after the login so that the elements are loaded.
Hi Vrushali & Team,
I have an ellipses button(…) represented as 3 dots button in my application which i want to click, but i was not able to click on it, Appium log is showing as click happened but not actually working on application/device.I have gone through your website which contains very useful information and some issues which actually relates to mine.can you guys please help me with a solution for this.I have been trying on this issue for past 3 weeks still didn’t find a solution for it.
P.S: NAF attribute is true for this element.
and one more thing,can i try sending KeyEvents to this particular element so that it can click…please help me !!!!
I tried with tapping on elements by giving co-ordinates and it works fine…but since its not reliable solution while running our scripts in production and changes with emulators as well. Is der any other work around for this issue ??
My code which works wid co-ordinates : driver.tap(1, 994, 147, 200);
Hi Veerendra,
As mentioned in blog we don’t recommended using co-ordinates. You can probably ask the developer to add a property to identify the element and use that for your testing.
Hi team,
U new for appium test,
My quistion is how handle NAF =true element
Because i getting error while handling password field ,i sent text but not enter in password field
Hi Can you please post the error?
Hi
I am dealing with same kind situation as mentioned in the post in iOS.
How to deal with NAF elements in iOS
Hii ,
Maybe this link – https://discuss.appium.io/t/how-to-handle-the-situation-when-naf-not-accessibility-friendly-is-true/536/3 might help you to solve the problem