Пример #1
0
        /// <summary>
        /// go to the list of cars sold
        /// </summary>
        public ListOfCarsSoldPage GoToSoldCars()
        {
            Locators    locators = new Locators();
            IWebElement element  = driver.FindElementByXPath(locators.CreateXPathForCarMark(car.Model));

            element.Click();
            return(new ListOfCarsSoldPage(driver, car));
        }
Пример #2
0
        /// <summary>
        /// Find the minimum cost from the list of cars sold
        /// </summary>
        /// <returns>
        /// minimum price
        /// </returns>
        public int MinimumCostOfCar()
        {
            Locators   loacators = new Locators();
            var        carList   = driver.FindElementsByXPath(loacators.briefInformationAboutCar);
            List <int> coasts    = new List <int>();

            foreach (IWebElement next in carList)
            {
                string[]      substrings = next.Text.Split();
                StringBuilder coast      = new StringBuilder(substrings[2] + substrings[3]);
                coasts.Add(int.Parse(coast.ToString()));
            }
            return(coasts.Min(n => n));
        }
Пример #3
0
        /// <summary>
        /// List all models in descending order of the number of cars sold
        /// </summary>
        public void DisplayAllModels()
        {
            Locators locators        = new Locators();
            var      wait            = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
            var      brandList       = wait.Until(drive => driver.FindElementsByXPath(locators.marks));
            var      sortedBrandList = from u in brandList
                                       orderby Int32.Parse(u.FindElement(By.TagName(locators.numberОfСarsTag)).Text) descending
                                       select u;

            foreach (IWebElement nextBrend in sortedBrandList)
            {
                Console.WriteLine("model name: " + nextBrend.FindElement(By.TagName(locators.modelNameTag)).Text + " number of cars of this brand sold : " + nextBrend.FindElement(By.TagName(locators.numberОfСarsTag)).Text);
            }
        }
Пример #4
0
 /// <summary>
 /// go to the list of models page for the selected brand
 /// </summary>
 public ListOfModelsPage GoToModelsPage()
 {
     if (CheckExistenceOfTheMark(car.Mark))
     {
         Locators    locators = new Locators();
         IWebElement element  = driver.FindElementByXPath(locators.CreateXPathForCarMark(car.Mark));
         ScrollWithOffset(element, 10, 10);
         element.Click();
         return(new ListOfModelsPage(driver, car));
     }
     else
     {
         throw new Exception("Chosen model is not available on the site");
     }
 }
Пример #5
0
        /// <summary>
        ///We check the availability of cars of the chosen mark
        /// </summary>
        /// <param name="carMark">chosen mark</param>
        public bool CheckExistenceOfTheMark(string carMark)
        {
            bool        result   = false;
            Locators    locators = new Locators();
            var         wait     = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
            IWebElement element  = wait.Until(drive => driver.FindElementByXPath(locators.allMarkButton));

            element.Click();
            var brandList = driver.FindElementsByXPath(locators.marks);

            foreach (IWebElement nextBrend in brandList)
            {
                if (carMark == nextBrend.FindElement(By.TagName(locators.markNameTag)).Text)
                {
                    result = true;
                }
            }
            return(result);
        }