Пример #1
0
        public bool FillOutForm(string Year, string Make, string Model, string BodyType, FinanceType FinanceType, Use Use)
        {
            dayStrings = new List <string>();
            bool driverInfoPageExist;

            SelectElement sltYear = driver.FindSelectElementWhenPopulated(By.Id("vehicleYear"), 30);

            sltYear.SelectByText(Year);

            SelectElement sltMake = driver.FindSelectElementWhenPopulated(By.Id("vehicleMake"), 30);

            sltMake.SelectByText(Make);

            SelectElement sltModel = driver.FindSelectElementWhenPopulated(By.Id("vehicleModel"), 30);

            sltModel.SelectByText(Model);

            try
            {
                SelectElement sltBody = driver.FindSelectElementWhenPopulated(By.Id("bodyStyles"), 30);
                sltBody.SelectByText(BodyType);
            }
            catch (Exception) {}


            System.Threading.Thread.Sleep(500);


            switch (FinanceType)
            {
            case FinanceType.Owned:
                owned.Click();
                break;

            case FinanceType.Financed:
                financed.Click();
                break;

            case FinanceType.Leased:
                Leased.Click();
                break;

            default:
                break;
            }

            SelectElement annualMileageSlt;
            SelectElement daysDrivenSlt;
            SelectElement businessUseSlt;


            switch (Use)
            {
            case Use.Commute:
                Commute.Click();
                //System.Threading.Thread.Sleep(3000);

                daysDrivenSlt = driver.FindSelectElementWhenPopulated(By.Id("daysDriven"), 30);
                IList <IWebElement> days; days = daysDrivenSlt.Options;
                foreach (var day in days)
                {
                    dayStrings.Add(day.GetAttribute("value").ToString());
                }



                daysDrivenSlt.SelectByValue("5");
                milesDriven.SendKeys("15");

                annualMileageSlt = driver.FindSelectElementWhenPopulated(By.Id("annualMileage"), 30);
                annualMileageSlt.SelectByText("12,001 - 15,000");



                break;

            case Use.Pleasure:
                Pleasure.Click();


                annualMileageSlt = driver.FindSelectElementWhenPopulated(By.Id("annualMileage"), 30);

                IList <IWebElement> miles = annualMileageSlt.Options;
                annualMileageSlt.SelectByText("12,001 - 15,000");
                break;

            case Use.Business:
                Business.Click();

                businessUseSlt = driver.FindSelectElementWhenPopulated(By.Id("typeOfBusinessUse"), 30);
                businessUseSlt.SelectByText("Clergy");
                annualMileageSlt = driver.FindSelectElementWhenPopulated(By.Id("annualMileage"), 30);
                annualMileageSlt.SelectByText("12,001 - 15,000");
                break;

            default:
                break;
            }


            Submit.Click();


            try
            {
                wait.Until(ExpectedConditions.ElementExists(By.Id("maritalStatus")));
                driverInfoPageExist = true;
            }
            catch (Exception e)
            {
                driverInfoPageExist = false;
            }

            //IWebElement radioBtnOwnership = this.RbOwned;
            //IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;
            //executor.ExecuteScript("arguments[0].click();", radioBtnOwnership);

            return(driverInfoPageExist);
        }