public string StartTestApp(string configDataPath) { string data = File.ReadAllText(configDataPath); JObject jdata = JObject.Parse(data); var config = jdata["config"]; var phoneConfig = jdata["phoneConfig"]; var appConfig = jdata["appConfig"]; var test = jdata["testData"]; var testResaultConfig = jdata["resaultConfig"]; Config.Instance.SetConfig((JObject)config); _phoneConfig = new PhoneConfig((JObject)phoneConfig); _appConfig = new AppConfig((JObject)appConfig); _connector = new Connector(_phoneConfig, _appConfig); _test = new Test((JArray)test); _testResault = new TestResault((JObject)testResaultConfig); _connector.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3); _test.startTest(); return(_testResault.CheckResault()); }
public Connector(PhoneConfig phoneConfig, AppConfig appConfig) { _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build(); _appiumLocalService.Start(); var appiumOptions = new AppiumOptions(); appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, phoneConfig.DeviceName); appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, phoneConfig.PlatformName); appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, phoneConfig.PlatformVersion); _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, appiumOptions); if (appConfig != null) { _driver.StartActivity(appConfig.AppPackage, appConfig.AppActivity); } }
public bool InitTest(Config config, PhoneConfig phoneConfig, AppConfig appConfig, TestResault testResault) { Config.Instance.SetConfig(config); _phoneConfig = phoneConfig; _appConfig = appConfig; _testResault = testResault; try { _connector = new Connector(_phoneConfig, _appConfig); _test = new Test(); }catch (Exception e) { _connector = null; _test = null; return(false); } return(true); }