Exemplo n.º 1
0
 public static IApp StartApp(Platform platform, string simulator, bool resetDevice = false)
 {
     Platform = platform;
     if (platform == Platform.Android)
     {
         if (resetDevice)
         {
             ResetAndroidEmulator();
         }
         return(ConfigureApp
                .Android
                .DeviceSerial(DeviceExtension.GetAndroidDevice(simulator))
                .InstalledApp(packageName)
                .StartApp());
     }
     try
     {
         if (resetDevice)
         {
             ResetiOSSimulator(simulator);
         }
         return(ConfigureApp
                .iOS
                .DeviceIdentifier(DeviceExtension.GetiOSDeviceID(simulator))
                .InstalledApp(packageName)
                .StartApp());
     }
     catch (Exception ex)
     {
         Console.WriteLine("********Error" + ex.Message);
         Console.WriteLine(ex.StackTrace);
         return(null);
     }
 }
Exemplo n.º 2
0
        static void ResetiOSSimulator(string iOSSimulator)
        {
            if (TestEnvironment.Platform.Equals(TestPlatform.Local))
            {
                var deviceId = DeviceExtension.GetiOSDeviceID(iOSSimulator);

                if (string.IsNullOrEmpty(deviceId))
                {
                    throw new ArgumentException($"No simulator found with device name [{iOSSimulator}]", iOSSimulator);
                }

                var shutdownProcess = Process.Start("xcrun", string.Format("simctl shutdown {0}", deviceId));
                shutdownProcess.WaitForExit();
                var eraseProcess = Process.Start("xcrun", string.Format("simctl erase {0}", deviceId));
                eraseProcess.WaitForExit();
            }
        }