Esempio n. 1
0
        public void WhenSelectTheCarByRandomValues(string numberCar)
        {
            researchPage = new ResearchPage();
            researchPage.SelectRandomCar();
            string[] newRandomCar = researchPage.GetRandomCarChoice();
            Car      newCar       = new Car(newRandomCar[0], newRandomCar[1], newRandomCar[2]);

            CarsCatalog.AddCar(numberCar, newCar);
        }
        private static Car SelectCarTrim(MainPage mainPage)
        {
            Logger.GetInstance().LogLine("STEP 2: Selecting 'research'.");
            mainPage.ClickResearchButton();

            ResearchPage researchPage = new ResearchPage();

            Logger.GetInstance().LogLine("STEP 3: Selecting random car data.");
            Car car = researchPage.SelectRandomCar();

            researchPage.ClickSearchButton();

            CarPage carPage = new CarPage();

            Logger.GetInstance().LogLine("STEP 4: Clicking 'compare trims' button.");

            if (carPage.IsCompareTrimsButtonPresent())
            {
                carPage.ClickCompareTrimsButton();
            }
            else
            {
                Logger.GetInstance().LogLine("WARNING: Failed to find 'Compare-trims' button, trying to select other car...");
                carPage.ClickResearchButton();

                ResearchPage secondTryResearchPage = new ResearchPage();
                car = secondTryResearchPage.SelectRandomCar();
                secondTryResearchPage.ClickSearchButton();

                CarPage secondTryCarPage = new CarPage();
                if (secondTryCarPage.IsCompareTrimsButtonPresent())
                {
                    secondTryCarPage.ClickCompareTrimsButton();
                }
                else
                {
                    Logger.GetInstance().LogLine("ERROR: Cannot find 'Compare trims' button: choosen parameters of car is incorrect!");
                    throw new System.Exception("ERROR: Cannot find 'Compare trims' button: choosen parameters of car is incorrect!");
                }
            }

            TrimsPage trimsPage = new TrimsPage();

            try
            {
                Logger.GetInstance().LogLine("STEP 5: Saving engine and trans data.");

                string engine       = trimsPage.GetCarEngine();
                string transmission = trimsPage.GetCarTransmission();

                car.Engine       = engine;
                car.Transmission = transmission;

                Logger.GetInstance().LogLine("STEP 6: Navigating to main page.");
                trimsPage.ClickHomeButton();

                return(car);
            }
            catch (NoSuchElementException)
            {
                Logger.GetInstance().LogLine("ERROR: Cannot find engine or trans data!");
                throw new System.Exception("ERROR: Cannot find engine or trans data!");
            }
        }
Esempio n. 3
0
 public void GivenSelectRandomCar()
 {
     _researchPage = new ResearchPage();
     _researchPage.SelectRandomCar();
 }