コード例 #1
0
        private static void PlayOnDevice(IEnumerable <LocalStep> stepList, DeviceTarget deviceTarget, string packagePath, string appiumServerIp, int appiumPort, string aaptPath)
        {
            using (var devicePilot = new DevicePilot())
            {
                Dictionary <string, string> persistantVariables = new Dictionary <string, string>();

                var isOk = devicePilot.StartDevice(deviceTarget, packagePath, appiumServerIp, appiumPort, aaptPath);
                if (!isOk)
                {
                    Console.WriteLine("Error opening device !");
                    Console.ReadKey();
                    return;
                }

                foreach (LocalStep step in stepList)
                {
                    Console.WriteLine($"Play STEP: command:{step.Command} target:{step.Target} value:{step.Value}");
                    string stepValue;
                    var    ret = devicePilot.ExecuteCommand(step.Command, step.Target, step.Value, step.Condition, step.TimedOutValue, ref persistantVariables, out stepValue);
                    if (!ret.isOk)
                    {
                        Console.WriteLine($"Error! Message: {ret.message} Result Value:{ret.resultValue}");
                        devicePilot.Dispose();
                        Console.ReadKey();
                        return;
                    }
                    Console.WriteLine("OK! " + ret.message);
                    Thread.Sleep(step.TimeBetweenSteps ?? 5 * 1000);
                }
            }
            Console.WriteLine("Finished without any error !");
            Console.ReadKey();
        }
コード例 #2
0
        private static IEnumerable <StepResult> PlayOnDevice(IEnumerable <LocalStep> stepList, DeviceTarget deviceTarget, string packagePath, string appiumServerIp, int appiumPort, string aaptPath)
        {
            using (var devicePilot = new DevicePilot())
            {
                var isOk = devicePilot.StartDevice(deviceTarget, packagePath, appiumServerIp, appiumPort, aaptPath);
                if (!isOk)
                {
                    Console.WriteLine("Error opening device !");
                    return(Enumerable.Empty <StepResult>());
                }

                var persistantVariables = new Dictionary <string, string>();
                var report = new List <StepResult>();
                int stepId = 0;
                foreach (LocalStep step in stepList)
                {
                    Console.WriteLine($"Play STEP: command:{step.Command} target:{step.Target} value:{step.Value}");
                    string stepValue;
                    var    ret = devicePilot.ExecuteCommand(step.Command, step.Target, step.Value, step.Condition, step.TimedOutValue, ref persistantVariables, out stepValue);

                    report.Add(new StepResult()
                    {
                        Command     = step.Command,
                        Target      = step.Target,
                        Value       = stepValue,
                        Message     = ret.message,
                        ResultValue = ret.resultValue.ToString(),
                        StepId      = stepId++
                    });

                    if (!ret.isOk)
                    {
                        Console.WriteLine($"Error! Message: {ret.message} Result Value:{ret.resultValue}");
                        return(report);
                    }
                    else
                    {
                        Console.WriteLine("OK! " + ret.message);
                        Thread.Sleep(step.TimeBetweenSteps ?? 5 * 1000);
                    }
                }

                Console.WriteLine("Finished without any error !");
                return(report);
            }
        }