/// <summary> /// /// Play a scenario on a local device (or emulator) /// /// Prerequisite: /// /// ANDROID: /// /// Intalled: /// - NodeJS & appium /// - Android: Android Studio with emulator /// /// TO DO iOS: /// /// Intalled: /// - NodeJS & appium /// - iOS: XCode with simulator /// /// /// Start android emulator: cmd /k "emulator.exe -netdelay none -netspeed full -avd GALAXYS7API24" /// Start appium /// /// /// </summary> /// <param name="args"></param> static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); Configuration = builder.Build(); var scriptPath = Configuration.GetValue <string>("ScriptPath"); var packagePath = Configuration.GetValue <string>("PackagePath"); var appiumServerIp = Configuration.GetValue <string>("AppiumServerIp"); var appiumPort = Configuration.GetValue <int>("AppiumPort"); var aaptPath = Configuration.GetValue <string>("AaptPath"); var deviceTarget = new DeviceTarget(); Configuration.Bind("DeviceTarget", deviceTarget); var stepList = ScriptParser.GetStepListFromScript(scriptPath); PlayOnDevice(stepList, deviceTarget, packagePath, appiumServerIp, appiumPort, aaptPath); }
/// <summary> /// /// Play a scenario on a local device (or emulator) /// /// Prerequisite: /// /// ANDROID: /// /// Intalled: /// - NodeJS & appium /// - Android: Android Studio with emulator /// /// TO DO iOS: /// /// Intalled: /// - NodeJS & appium /// - iOS: XCode with simulator /// /// /// Start android emulator: cmd /k "emulator.exe -netdelay none -netspeed full -avd GALAXYS7API24" /// Start appium /// /// /// </summary> /// <param name="args"></param> static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables(); Configuration = builder.Build(); var dataDir = Configuration.GetValue <string>("DataDir"); var scriptPath = Path.Combine(dataDir, Configuration.GetValue <string>("ScriptFile")); var packagePath = Path.Combine(dataDir, Configuration.GetValue <string>("PackageFile")); var buildToolsVersion = Configuration.GetValue <string>("ANDROID_BUILD_TOOLS_VERSION"); var aaptPath = Path.Combine(Configuration.GetValue <string>("ANDROID_HOME"), "build-tools", $"{buildToolsVersion}", "aapt.exe"); CheckFileExists(scriptPath); CheckFileExists(packagePath); CheckFileExists(aaptPath); var appiumServerHost = Configuration.GetValue <string>("AppiumHost"); var appiumPort = Configuration.GetValue <int>("AppiumPort", 4723); var deviceTarget = new DeviceTarget(); Configuration.Bind("DeviceTarget", deviceTarget); var stepList = ScriptParser.GetStepListFromScript(scriptPath); var report = PlayOnDevice(stepList, deviceTarget, packagePath, appiumServerHost, appiumPort, aaptPath); var reportPath = Path.Combine(dataDir, Guid.NewGuid().ToString("N") + ".json"); File.WriteAllText(reportPath, JsonConvert.SerializeObject(report, Formatting.Indented)); Console.Write($"Run report written to {reportPath}"); }