Forum Xamarin.Forms

How to find an element using the REPL if it has no id?

Abel.9682Abel.9682 USMember
edited November 2015 in Xamarin.Forms

I'm trying to do some UI Tests and I have an element on a view defined using XAML (no code behind is allowed on this project). When I launch the REPL and ask for the tree of elements I get this:

[[object CalabashRootView] > PhoneWindow$DecorView]
[ActionBarOverlayLayout] id: "decor_content_parent"
[FrameLayout > ... > RendererFactory_DefaultRenderer] id: "content"
[EntryRenderer > EntryEditText]
[EntryRenderer > EntryEditText]
[RendererFactory_DefaultRenderer > ButtonRenderer]
[Button] text: "LOGIN"
[RendererFactory_DefaultRenderer > ButtonRenderer]
[Button] text: "Register for trial"
[View] id: "statusBarBackground"
[View] id: "navigationBarBackground"

I need to access those two EntryEditText and enter some text but I can't seem to find how to specify those two controls.
Is there a way to iterate over the elements with an ID such as "decor_content_parent" or "content" and find those two?

I tried this:

app.EnterText(c=>c.Id("content").Child().Index (1), new string('9', 15));

and also this:

app.EnterText(c=>c.Id("content").Sibling().Index (1), new string('9', 15));

and this:

app.EnterText(c=>c.Id("content").Descendant().Index (1), new string('9', 15));

but I still can't access those two fields.

This is the XAML:

< Entry Placeholder="e-mail"
Text="{Binding TxtEmail}"
< /Entry>

< Entry Placeholder="password"
Text="{Binding TxtPassword}"
< /Entry>

Thanks :)


  • adamkempadamkemp USInsider, Developer Group Leader mod

    See this document. Note especially the part about adding some code to the platform-specific projects using ViewInitialized.

Sign In or Register to comment.