Beispiel #1
0
        public void InitializeDefaultClicks()
        {
            RegistrationClicks.Clear();
            TaxiOrderingClicks.Clear();
            DataCleaningClicks.Clear();
            KeyboardInputs.Clear();
            EnterPresses.Clear();

            int number = 0;

            RegistrationClicks.Add(number++, new Click(new PointF(0.5f, 0.5f), "Click phone number field", 1000));
            KeyboardInputs.Add(number++, new KeyboardInput("Enter phone number", 1000));
            RegistrationClicks.Add(number++, new Click(new PointF(0.5f, 0.940269768f), "Click Next", 1500));
            RegistrationClicks.Add(number++, new Click(new PointF(0.317307681f, 0.190104172f), "Click 1st field of code", 0));
            KeyboardInputs.Add(number++, new KeyboardInput("Enter code", 3000));
            RegistrationClicks.Add(number++, new Click(new PointF(0.5f, 0.274566472f), "Click e-mail field", 1000));
            KeyboardInputs.Add(number++, new KeyboardInput("Enter e-mail", 1500));
            EnterPresses.Add(number++, new EnterPress("Press Enter", 700));
            KeyboardInputs.Add(number++, new KeyboardInput("Enter first name", 1500));
            EnterPresses.Add(number++, new EnterPress("Press Enter", 700));
            KeyboardInputs.Add(number++, new KeyboardInput("Enter last name", 1500));
            RegistrationClicks.Add(number++, new Click(new PointF(0.5f, 0.9441233f), "Click Next", 4500));

            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.917148352f), "Click Search destination", 1000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.153214768f), "Click Pickup location", 1000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.9137324f, 0.153214768f), "Click x in Pickup location Field", 500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.201094389f), "Click Where to?", 1000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.9137324f, 0.201094389f), "Click x in Where to? Field", 500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.153214768f), "Click Pickup location", 500));
            KeyboardInputs.Add(number++, new KeyboardInput("Enter address from", 1500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.366088629f), "Click address from", 500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.201094389f), "Click Where to?", 500));
            KeyboardInputs.Add(number++, new KeyboardInput("Enter address to", 1500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.254335254f), "Click address to", 7000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.943159938f), "Click Select Bolt", 3000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.943159938f), "Click Request Bolt", 1000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.9f, 0.9375f), "Click OK in messagebox (only once)", 14000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.92957747f, 0.8795761f), "Click chevron-up button", 1500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.125f, 0.8265896f), "Click Call", 3000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.653179169f), "DoubleClick to copy number", 1500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(1.04797983f, 0.921875f), "Click Home", 1500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.6919014f, 0.383429676f), "Click Bolt icon", 3000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.8556338f, 0.8265896f), "Click Cancel", 1500));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 0.9633911f), "Click Cancel ride", 1000));
            TaxiOrderingClicks.Add(number++, new Click(new PointF(0.5f, 1.0f), "Click reason for cancellation", 1000));

            DataCleaningClicks.Add(number++, new Click(new PointF(1.04797983f, 0.921875f), "Click Home", 1000));
            DataCleaningClicks.Add(number++, new Click(new PointF(0.8863636f, 0.3857729f), "Click Settings icon", 3000));
            DataCleaningClicks.Add(number++, new Click(new PointF(0.5f, 0.760601938f), "Click applications in settings", 1500));
            DataCleaningClicks.Add(number++, new Click(new PointF(0.5f, 0.24897401f), "Click Bolt in applications", 3000));
            DataCleaningClicks.Add(number++, new Click(new PointF(0.7323232f, 0.432284534f), "Click Clear Data", 1000));
            DataCleaningClicks.Add(number++, new Click(new PointF(0.7929293f, 0.6019152f), "Click OK", 1500));
            DataCleaningClicks.Add(number, new Click(new PointF(1.04797983f, 0.921875f), "Click Home", 1000));
        }
Beispiel #2
0
        public void LoadClicksFromFile()
        {
            RegistrationClicks.Clear();
            TaxiOrderingClicks.Clear();
            DataCleaningClicks.Clear();
            KeyboardInputs.Clear();
            EnterPresses.Clear();

            using (FileStream fs = new FileStream(ClicksFilePath, FileMode.OpenOrCreate))
            {
                using (StreamReader sr = new StreamReader(fs, Encoding.Default))
                {
                    int actionsCount = 0;
                    while (!sr.EndOfStream && actionsCount < ActionsCount)
                    {
                        if (Enum.TryParse(sr.ReadLine(), out Actions action))
                        {
                            string line;
                            string jobjectString = "";
                            do
                            {
                                line           = sr.ReadLine();
                                jobjectString += line;
                            } while (line != "}");

                            switch (action)
                            {
                            case Actions.Click:
                            {
                                if (actionsCount < RegistrationActionsCount)
                                {
                                    RegistrationClicks.Add(actionsCount,
                                                           JsonConvert
                                                           .DeserializeObject <Click>(
                                                               jobjectString));
                                }
                                else if (actionsCount <
                                         TaxiOrderingActionsCount + RegistrationActionsCount)
                                {
                                    TaxiOrderingClicks.Add(actionsCount,
                                                           JsonConvert
                                                           .DeserializeObject <Click>(
                                                               jobjectString));
                                }
                                else
                                {
                                    DataCleaningClicks.Add(actionsCount,
                                                           JsonConvert
                                                           .DeserializeObject <Click>(
                                                               jobjectString));
                                }

                                break;
                            }

                            case Actions.KeyboardInput:
                            {
                                KeyboardInputs.Add(actionsCount,
                                                   JsonConvert
                                                   .DeserializeObject <KeyboardInput>(
                                                       jobjectString));
                                break;
                            }

                            case Actions.EnterPress:
                            {
                                EnterPresses.Add(actionsCount,
                                                 JsonConvert
                                                 .DeserializeObject <EnterPress>(
                                                     jobjectString));
                                break;
                            }
                            }
                        }
                        else
                        {
                            throw new Exception(
                                      "Действие не было опознано. Файл кликов \"" +
                                      ClicksFilePath + "\" был повреждён.");
                        }

                        actionsCount++;
                    }
                }
            }
        }