Accessing the EditText password field

879 views
Skip to first unread message

Marius Bob

unread,
Jan 24, 2014, 7:09:04 AM1/24/14
to appium-...@googlegroups.com

I’ve noticed that for password fields in Android, uiautomator(and obviously also Appium) couldn’t find the key located in the strings.xml file.

As you can see from the screenshots attached, the value of the password field(the hint string) is not visible.

So, if I want to find the element by using the key from the strings.xml file, the test will fail.

 

Is there a way to fix this issue on the layout file?

I did some research on internet and it seems there are some issues. I’m asking about this, maybe anyone could give me a point in solving this.

 

A quick workaround would be to get all the EditTexts fields in a list and access them by their index….

 

Thanks!

-Marius

 

 

text1.png

 

 

 

 

text2.png

image001.png
image002.png

Igor Gladun

unread,
Jan 24, 2014, 8:32:31 AM1/24/14
to appium-...@googlegroups.com
https://github.com/appium/appium/issues/244

пятница, 24 января 2014 г., 14:09:04 UTC+2 пользователь Bob Marius написал:

bootstrap online

unread,
Jan 24, 2014, 9:44:44 AM1/24/14
to Igor Gladun, appium-...@googlegroups.com
I suggest using a resource id.

<!-- res/layout/login.xml -->
android:id="@+id/my_password"


--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Marius Bob

unread,
Jan 24, 2014, 9:52:09 AM1/24/14
to bootstrap online, Igor Gladun, appium-...@googlegroups.com

Yes, but this will imply using Selendroid and didn’t write the tests with selendroid. I’m trying to make use of localizable.strings and strings.xml since I have the same app for both iOS and Android platforms and dev team struggled create a match for all the keys from the two files J.

That’s a weird a bit, but I’ll make it work somehos :P

 

 

Thanks!

bootstrap online

unread,
Jan 24, 2014, 9:55:14 AM1/24/14
to Marius Bob, Igor Gladun, appium-...@googlegroups.com
I'm using resource ids with uiautomator.

Marius Bob

unread,
Jan 24, 2014, 10:26:02 AM1/24/14
to bootstrap online, appium-...@googlegroups.com

Are you referring to this: http://developer.android.com/tools/help/uiautomator/UiSelector.html#resourceId(java.lang.String)  ?

 

What if my test project is not an Android project?

bootstrap online

unread,
Jan 24, 2014, 10:41:06 AM1/24/14
to Marius Bob, appium-...@googlegroups.com
For successful cross platform automation, you'll need:

Android

- strings.xml
- content descriptions
- resource id

iOS

- Localizable.strings
- accessibility identifiers / accessibility labels

 Localizable.strings should match strings.xml. The content descriptions / resource ids should match up with accessibility labels and identifiers.

Marius Bob

unread,
Jan 24, 2014, 10:59:36 AM1/24/14
to bootstrap online, appium-...@googlegroups.com

Thanks for your information.

But I didn’t understand how is possible to access the resource ids with uiautomator in your tests..

I’m pretty sure, something is missing to me J

bootstrap online

unread,
Jan 24, 2014, 11:10:03 AM1/24/14
to Marius Bob, appium-...@googlegroups.com
Use the standard find by id. That will look for resource ids or strings.xml ids on Android.

Marius Bob

unread,
Jan 24, 2014, 11:23:37 AM1/24/14
to bootstrap online, appium-...@googlegroups.com

I have the following EditText in the layout file:

 

    android:id="@+id/signin_password"

                android:hint="@string/signIn.password.placeholder"

 

And I get an error when I try to find the element by id(not using Selendroid).

bootstrap online

unread,
Jan 24, 2014, 11:37:49 AM1/24/14
to Marius Bob, appium-...@googlegroups.com
Use uiautomatorviewer to get the correct id. 

Marius Bob

unread,
Jan 24, 2014, 11:44:40 AM1/24/14
to bootstrap online, appium-...@googlegroups.com

With uiautomatorviewer I see “com.mywebgrocer.Albertsons:id/signin_password” as the value of resource-id….

But the element is still not found …

 

Device’s android version is 4.4.2, so it should alright

bootstrap online

unread,
Jan 24, 2014, 11:47:50 AM1/24/14
to Marius Bob, appium-...@googlegroups.com

On Fri, Jan 24, 2014 at 11:44 AM, Marius Bob <znu...@gmail.com> wrote:
com.mywebgrocer.Albertsons:id/signin_password

If you find by id using "com.mywebgrocer.Albertsons:id/signin_password" on an API 18 device, it should work.
Reply all
Reply to author
Forward
0 new messages