Run Xamarin.UITest on Physical Device

bryan1bryan1 IEMember ✭✭

What I want:
To run UI tests against a pre installed app on a physical iPod from Visual Studio on PC. All development of this app has been done entirely using this device currently running ios 11.26 (i.e. no simulator) using Visual Studio connecting to a mac mini via the xamarin agent. I can't have the UI test install the application during setup or anything like that, it needs to launch the app which is already installed.

What I've tried:
Added xamarin ui test project to my solution. Added a reference to my ***.iOS.App project to the test project. In my ***.iOS.App project I added a reference Xamarin.TestCloud.Agent nuget package. In my appdelegate I added the call the Xamarin.Calabash.Start(). In my test I tried to configure the IApp object in several different ways using a mix of specifying the AppBundle and DeviceIdentifier (which I obtained in ITunes - the Device UDID). If I'm testing on a local device I don't think I need the reference to test cloud or the call to start calabash but the documentation was a bit vague.

Is it possible to run UITests on Physical devices via visual studio on Windows? The documentation doesn't clarify if its talking about from physical device or simulator.

When I run the test I get : SetUp : System.Exception : iOS tests are not supported on Windows.

What I also tried
Opened the solution on Visual Studio on my mac. Added the UI test project. I could not add a reference from the test project to the ***.iOS.App like I could on Windows but I pened the Unit test window, right click Test Apps, and selected the proejct that needed to be tested. Again I tried to configure the iApp object in the Setup method in several ways, specifying the app bundle and device identifier. When the app bundle was included I got an exception saying "Could not find key : CFBundleExecutable".

If I don't want the app to run in the siumulator should i be using the AppBundle method? When I keep the config very simple and just use ConfigureApp.iOS.StartApp() the application output proceeds well. Output

1 - LaunchTestAsync:
deviceId: 8d725........ //It's picked up my connected iPod which is a positive sign

1 - Unsuccessful

The Test output itself says:

SetUp : Calabash.XDB.Core.Exceptions.DeviceAgentException : Failed to install DeviceAgent.

In Summary:
I'm having slightly more success from my mac, currently getting the following error SetUp : Calabash.XDB.Core.Exceptions.DeviceAgentException : Failed to install DeviceAgent. But I'd prefer to stay on PC so if that was possible I'd like to switch to fixing problems there. currently getting the following error SetUp : System.Exception : iOS tests are not supported on Windows.

Answers

  • AnthonyMehallelAnthonyMehallel USMember ✭✭✭

    Hi @bryan1

    it is not possible to launch iOS UI Test on Windows.

    Anthony

  • bryan1bryan1 IEMember ✭✭
    edited April 2018

    Thanks @AnthonyMehallel that helped me get on the right track.

    For anyone else coming across this I solved "Failed to install DeviceAgent" problem by either re-adding the Xamarin.UITest package or following the advice given here or perhaps a combination of both.

    The next issue I'm facing is that when the application launches it freshly deploys the app onto the phone. This is a big issue for me as after a fresh install the user needs to re-sync everything which is not a fast process.

    My question is how can I get the application to launch using the version of the app already installed. I've tried using the ConfigureApp.iOS.InstalledApp(bundleId) but it hasn't made any difference. Because of the time taken to do a synchronization (30+ minutes) I'm restricted to just trying out things in a hit and miss fashion.

    Thanks to anyone who can help

    ******Edit: I have solved this issue******
    using .StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear)

    But this has revealed a further issue

    Setup : System.Exception : Unable to contact test backend running in app. A common cause is that the app is not properly linked with Calabash. Please verify that it includes the Calabase component. (As mentioned above in the app delegate i put in a call to Xamarin.Calabash.Start() . I don't surround with if ENABLE_TEST_CLOUD as i'm exclusively running the app via running the tests at the moment

  • AnthonyMehallelAnthonyMehallel USMember ✭✭✭

    In your AppInitializer you can specify the type of appDataMode

    for exemple : app = AppInitializer.StartApp(platform, Xamarin.UITest.Configuration.AppDataMode.DoNotClear)

  • bryan1bryan1 IEMember ✭✭

    Thanks @AnthonyMehallel I played around with the options and figured out exactly what you said. I updated my original if you have come across the next issue I'm currently facing

Sign In or Register to comment.