UITest - What is the proper way to fill in Oauth username & password in a web view on an iPhone?

VeniLillkallVeniLillkall FIUniversity ✭✭

I'm trying to find a suitable piece of code to fill in username and password based on a Css selector on UITest for both iOS and Android - considering also effects of different screen sizes. Closest thing so far has been calling the method below twice to fill in username and password separately.

public void EnterCssText(string cssSelector, string text)
{
   app.ScrollDownTo(c => c.Css(cssSelector));    // make sure the field is visible
   app.EnterText(c => c.Css(cssSelector), text);
   app.DismissKeyboard();
}

On Android this works fine and on iPads, but on an iPhone I end up with both username and password typed in the username field - the sign in fails with empty password. Everything is fine in the test log on Test Cloud:

21-04-2016 11:51:00.679 +02:00 - 144512 - Entering text '[email protected]' in element matching Css("#user") at coordinates [ 160, 476 ].
21-04-2016 11:51:08.445 +02:00 - 152278 - Attempting to dismiss keyboard
21-04-2016 11:51:08.585 +02:00 - 152418 - Scrolling down to Css("#password")
21-04-2016 11:51:09.504 +02:00 - 153337 - Entering text 'yyyyyyyyy' in element matching Css("#password") at coordinates [ 140, 136 ].
21-04-2016 11:51:14.458 +02:00 - 158292 - Attempting to dismiss keyboard
21-04-2016 11:51:14.572 +02:00 - 158405 - Scrolling down to Css("#signin")
21-04-2016 11:51:15.511 +02:00 - 159344 - Tapping element matching Css("#signin") at coordinates [ 140, 205 ].

I can't seem to come up with any code that would work properly on an iPhone. Adding app.Tap(...) before EnterText does not help.
Any idea of what is going on? Sounds really like a bug but a quick workaround would be nice.

Xamarin.UITest version: 1.3.7

Tagged:

Best Answer

Answers

  • iltafkhalidiltafkhalid USMember

    How to get instance to app while working with xamarin iOS ? I am stuck at this issue for some days.

  • VeniLillkallVeniLillkall FIUniversity ✭✭

    I struggled with that also - maybe this is what you're looking for (from our iOS test project):

    static string PathToApp = "../../../iOS/bin/iPhone/Debug/App.app";
    
    // NOTICE: PreferIdeSettings() is needed for Xamarin Studio
    // http://forums.xamarin.com/discussion/43301/xamarin-uitest-and-test-cloud-setup-for-both-vs2013-and-xamarin-studio-ides
    
    #if __IOSTEST__ && DEBUG
    app = ConfigureApp.iOS.AppBundle(PathToApp).PreferIdeSettings().StartApp(Xamarin.UITest.Configuration.AppDataMode.Clear);
    #else
    throw new Exception("Use Debug build for iOS tests - embedded Xamarin Test Cloud Agent is required");
    #endif
    
Sign In or Register to comment.