Exemplo n.º 1
0
        public static AddAnotherVehiclePage AddVehicle(this VehicleEntryPage vinEntryPage, VehicleInformation vehicleInformation)
        {
            ParameterValidator.ValidateNotNull(vinEntryPage, "Vehicle Entry Page");
            ParameterValidator.ValidateNotNull(vehicleInformation, "Vehicle Information");

            //1. Enter VIN or select I don't have CIN
            VehicleDescriptorsPage vehicleInfoDescriptorsPage = null;
            VehicleBodyTypePage    vehicleBodyTypePage        = null;

            if (vehicleInformation.VIN != null)
            {
                // Enter VIN
                vinEntryPage.EnterVin(vehicleInformation.VIN);

                // Check VIN status
                if (vehicleInformation.VinStatus == VinStatus.Unknown)
                {
                    var unknownPage = vinEntryPage.SelectNextButton();
                    if (unknownPage is VehicleDescriptorsPage)
                    {
                        vehicleInfoDescriptorsPage = unknownPage;
                    }
                    else
                    {
                        vehicleBodyTypePage = unknownPage;
                    }
                }
                else if (vehicleInformation.VinStatus == VinStatus.Invalid)
                {
                    vehicleInfoDescriptorsPage = vinEntryPage.SelectNextButton <VehicleDescriptorsPage>();
                }
                else
                {
                    vehicleBodyTypePage = vinEntryPage.SelectNextButton <VehicleBodyTypePage>();
                }
            }
            else
            {
                vehicleInfoDescriptorsPage = vinEntryPage.SelectHasNoVin();
            }

            // If VIN returned NO-HIT
            if (vehicleInfoDescriptorsPage != null)
            {
                // Verification
                vehicleInfoDescriptorsPage.ValidateVehicleDescriptorsPageDisplayed();

                // Complete year, make, model, brakes and airbags and select next
                vehicleBodyTypePage = vehicleInfoDescriptorsPage.EnterVehicleDescription(vehicleInformation.VehicleDescription).SelectNextButton();
            }

            //Verification
            vehicleBodyTypePage.ValidateVehicleBodyTypePageDisplayed();

            //2. Enter vehicle details
            return(vehicleBodyTypePage.EnterVehicleDetails(vehicleInformation));
        }
Exemplo n.º 2
0
        public static AddAnotherVehiclePage EnterVehicleDetails(this VehicleBodyTypePage vehicleBodyTypePage, VehicleInformation vehicleInformation)
        {
            ParameterValidator.ValidateNotNull(vehicleBodyTypePage, "vehicleBodyTypePage");
            ParameterValidator.ValidateNotNull(vehicleInformation, "vehicleInformation");

            //1. Select Body type @BodyType
            vehicleBodyTypePage.SelectBodyType(vehicleInformation.BodyType);

            dynamic currentPage = vehicleBodyTypePage;

            //2. Set GVW or seat cap
            if (vehicleInformation.GVW != null)
            {
                //Select Next Button
                VehicleGVWPage vehicleInfoGVWPage = vehicleBodyTypePage.SelectNextButton <VehicleGVWPage>();
                // Verification
                vehicleInfoGVWPage.ValidateVehicleGVWPageDisplayed();

                //Set GVW
                vehicleInfoGVWPage.SelectGrossWeight(vehicleInformation.GVW);
                currentPage = vehicleInfoGVWPage;
            }
            else if (vehicleInformation.SeatCap != null)
            {
                // Select Next button
                VehicleSeatCapPage vehicleInfoSeatCap = vehicleBodyTypePage.SelectNextButton <VehicleSeatCapPage>();
                // Verification
                vehicleInfoSeatCap.ValidateVehicleSeatCapPageDisplayed();

                // Set Seat Cap
                vehicleInfoSeatCap.EnterSeatCap(vehicleInformation.SeatCap);
                currentPage = vehicleInfoSeatCap;
            }

            //Select Next
            if (vehicleInformation.ClassificationFlow != null)
            {
                currentPage.SelectNextButton <VehicleClassificationPage>();
            }
            else if (vehicleInformation.FactorFlow != null)
            {
                currentPage.SelectNextButton <VehicleFactorPage>();
            }
            else if (vehicleInformation.ClassificationOverride != null)
            {
                currentPage.SelectNextButton <VehicleClassificationOverridePage>();
            }
            else
            {
                currentPage.SelectNextButton <VehiclePhysicalDamagePage>();
            }

            //3.1 Select vehicle classification and select next
            if (vehicleInformation.ClassificationFlow != null)
            {
                VehicleClassificationPage vehicleClassificationPage = new VehicleClassificationPage();
                // Verification
                vehicleClassificationPage.ValidateVehicleClassificationPageDisplayed();

                for (int i = 0; i < vehicleInformation.ClassificationFlow.Length - 1; i++)
                {
                    vehicleClassificationPage.SelectClassificationFlow <VehicleFactorPage>(vehicleInformation.ClassificationFlow[i]);
                }

                if (vehicleInformation.FactorFlow != null)
                {
                    vehicleClassificationPage.SelectClassificationFlow <VehicleFactorPage>(vehicleInformation.ClassificationFlow.Last());
                }
                else if (vehicleInformation.ClassificationOverride != null)
                {
                    vehicleClassificationPage.SelectClassificationFlow <VehicleClassificationOverridePage>(vehicleInformation.ClassificationFlow.Last());
                }
                else
                {
                    vehicleClassificationPage.SelectClassificationFlow <VehiclePhysicalDamagePage>(vehicleInformation.ClassificationFlow.Last());
                }
            }

            //3.2 Select vehicle factor and select next
            if (vehicleInformation.FactorFlow != null)
            {
                VehicleFactorPage vehicleFactorPage = new VehicleFactorPage();
                // Verification
                vehicleFactorPage.ValidateVehicleFactorPageDisplayed();

                for (int i = 0; i < vehicleInformation.FactorFlow.Length - 1; i++)
                {
                    vehicleFactorPage.SelectFactorFlow <VehicleFactorPage>(vehicleInformation.FactorFlow[i]);
                }

                if (vehicleInformation.ClassificationOverride != null)
                {
                    vehicleFactorPage.SelectFactorFlow <VehicleClassificationOverridePage>(vehicleInformation.FactorFlow.Last());
                }
                else
                {
                    vehicleFactorPage.SelectFactorFlow <VehiclePhysicalDamagePage>(vehicleInformation.FactorFlow.Last());
                }
            }

            //3.3 Select vehicle classification override and select next
            if (vehicleInformation.ClassificationOverride != null)
            {
                VehicleClassificationOverridePage vehicleClassificationOverridePage = new VehicleClassificationOverridePage();
                // verification
                vehicleClassificationOverridePage.ValidateVehicleClassificationOverridePageDisplayed();

                for (int i = 0; i < vehicleInformation.ClassificationOverride.Length - 1; i++)
                {
                    vehicleClassificationOverridePage.SelectClassificationOverride <VehicleClassificationOverridePage>(vehicleInformation.ClassificationOverride[i]);
                }
                vehicleClassificationOverridePage.SelectClassificationOverride <VehiclePhysicalDamagePage>(vehicleInformation.ClassificationOverride.Last());
            }
            VehiclePhysicalDamagePage vehicleInfoPhysicalDamagePage = new VehiclePhysicalDamagePage();

            // Verification
            vehicleInfoPhysicalDamagePage.ValidateVehiclePhysicalDamagePageDisplayed();

            //4. Set Physical Damage and select next
            AddAnotherVehiclePage addAnotherVehiclePage = vehicleInfoPhysicalDamagePage.EnterPhysicalDamage(vehicleInformation.PhysicalDamage).SelectNextButton <AddAnotherVehiclePage>();

            // Verification
            addAnotherVehiclePage.ValidateAddAnotherVehiclePageDisplayed();

            return(addAnotherVehiclePage);
        }