Beispiel #1
0
        public static void ClassInit(TestContext context)
        {
            // Start Appium Server
            var avdOptions = new KeyValuePair<string, string>("--avd", "Emulator-Api19-Default");
            var avdParamsOptions = new KeyValuePair<string, string>("--avd-args", "\"-scale 0.50\"");
            OptionCollector args = new OptionCollector();
            args.AddArguments(avdOptions);
            args.AddArguments(avdParamsOptions);

            service = new AppiumServiceBuilder().WithArguments(args).UsingAnyFreePort().Build();
            service.Start();
            Assert.IsTrue(service.IsRunning);

            // Start Appium Client
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.SetCapability("deviceName", "Android Emulator");
            capabilities.SetCapability("platformName", "Android");
            capabilities.SetCapability("app", "C:\\Git\\qa-academy\\2015\\MobileTesting\\testapp\\android-rottentomatoes-demo-debug.apk");
            driver = new AndroidDriver<AndroidElement>(service.ServiceUrl, capabilities);
        }
Beispiel #2
0
        public Response Execute(Command commandToExecute)
        {
            Response result = null;

            try
            {
                if (commandToExecute.Name == DriverCommand.NewSession)
                {
                    Service?.Start();
                    RealExecutor = ModifyNewSessionHttpRequestHeader(RealExecutor);
                }

                result = RealExecutor.Execute(commandToExecute);
                return(result);
            }
            catch (Exception e)
            {
                if ((commandToExecute.Name == DriverCommand.NewSession))
                {
                    Service?.Dispose();
                }

                throw;
            }
            finally
            {
                if (result != null && result.Status != WebDriverResult.Success &&
                    commandToExecute.Name == DriverCommand.NewSession)
                {
                    Dispose();
                }

                if (commandToExecute.Name == DriverCommand.Quit)
                {
                    Dispose();
                }
            }
        }
        public Response Execute(Command commandToExecute)
        {
            Response result = null;

            if (commandToExecute.Name == DriverCommand.NewSession && this.Service != null)
            {
                Service.Start();
            }

            try
            {
                result = RealExecutor.Execute(commandToExecute);
                return(result);
            }
            catch (Exception e)
            {
                if ((commandToExecute.Name == DriverCommand.NewSession) && (Service != null))
                {
                    Service.Dispose();
                }
                throw e;
            }
            finally
            {
                if (result != null && result.Status != WebDriverResult.Success &&
                    commandToExecute.Name == DriverCommand.NewSession && Service != null)
                {
                    Service.Dispose();
                }

                if (commandToExecute.Name == DriverCommand.Quit && Service != null)
                {
                    Service.Dispose();
                }
            }
        }