Can not get resource id in Appium Inspector Window

Hi,
I’m testing the a android app using Appium, But not able to detect the text field /Button using the id of those views.
example:

driver.findElement(By.id(“com.example.saibal.myapplication:id/UserEmail”)).sendKeys(“[email protected]”);
driver.findElement(By.id(“com.example.saibal.myapplication:id/SubmitButton”)).click();

Using these 2 statements in my java main function I can’t able to detect the EditText or the Button,

I know it can be done using the "By.name " at the place of “By.id” but I want to detect the views using those id value. I this case I visit the Inspector Window, but I found there, the “resource id” is missing.

I think this might be the case, that’s why the “By.id” notation in my script can’t detect the EditText and Button. I have attached the screen shot here.

Kindly help me in this issue.

Thank You

Are you sure there’s actually an ID on those controls?

<EditText
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:inputType=“textPersonName”
android:hint=“User Full Name”
android:ems=“10”
android:id=“@+id/UserName”
android:padding=“10dp”
android:tag=“UserFullName”/>

I think this android id will be the resource id for the control.
am I right or wrong ? :confused:

you can double check in android “UI Automator Viewer”.

@ Aleksei “UI Automator Viewer” does not show any Id for the views.

Does it mean something ? any idea ?

Friends,
Anything other than By.name { driver.findElement(By.name(“Submit”)).click() } I can use to detect the views?

For your information I have tried some other method also like By.tagName, By.xpath also but those technique failed to detect an element.

it means that there is no ID :slight_smile: and you should fix in client this.
try:

driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().text(\""+ your_text_variable + "\")")));

what should I write in “+ your_text_variable +” ?
I’m not willing to use the “hint” or “text” property of any Android view. Because it will not work in any action bar icon.

String your_text_variable = "User Full Name";

In that case I can use driver.findElement(By.name(“User Full Name”));

But try to understand my problem, I can use only this text or hint in any EditText field or Button? what should I do if there is no any Text or Hint like Action Bar icons. example given below:

what should I write to identify this setting button ? here is no any text or hint.

you can not use by name with latest appium. what is your appium version?

When you have no choose but only text in element you have few ways to find element. If you have element ID (best case) you should use ID.

I’m using AppiumForWindows_1_4_13_1

migrate to 1.6.X - it is only few clicks for windows. install nodeJs and in command line install appium.

Ok I have Updated it to AppiumForWindows_1_4_16_1.

It is almost same, But I can’t find out any suitable script to identify that action bar Setting button.

Friends at last I got the solution to identify each views:

To identify and SetText to a edit text:

driver.findElement(By.xpath(“//android.widget.EditText[@index=‘0’]”)).sendKeys(“London”);

Individual element of EditText will be identified by it’s “index” value or “content-desc” value. Prefered to set “content-desc” value because it’s unique identity will be in out hand. we can set this view property as title in app’s xml file. example:

android:title=“Settings”

For Button identification:

driver.findElement(By.xpath(“//android.widget.Button[@index=‘1’]”)).click();
You can use “content-desc” too at the place of index.

For spinner/Drop-down Menu:

driver.findElement(By.xpath(“//android.widget.Spinner[@index=‘1’]”)).click();
driver.findElement(By.xpath(“//android.widget.TextView[@index=‘1’]”)).click();

Here the 2nd line choose the option of index 1 of the list of drop-down values. index started from value 0. I choose the 2nd value of the list in this example.

Thank you

You can also use the combination of class name and bound values to locate elements.

Just like this.
driver.findElement(By.xpath("//android.widget.TextView[@bounds=’[0,554][480,626]’]")).click();

Cheers

Hello,

I am trying with driver.findElement(By.xpath("//android.view.View[@bounds=’[0,72][1080,222]’]")).click();
but it is not working and I upload a screen shot. Could you please suggest me regarding the issue ?