Exemplo n.º 1
0
 public BaseElement(By locator, string name)
 {
     this.Name    = name;
     this.driver  = SingleWebDriver.GetInstance();
     this.locator = locator;
     Logger.GetInstance().LogLine($"Created '{Name}' element.");
 }
        public void LowestDiscountCalculationCheck()
        {
            Logger.GetInstance().LogLine($"STEP: Opening main page...");
            MainPage mainPage = new MainPage();

            mainPage.SelectCategory(FileUtils.GetLocalizedString("Indie"));
            Logger.GetInstance().LogLine($"STEP: Selected 'indie' category.");

            CategoryPage gameCategoryPage = new CategoryPage(FileUtils.GetLocalizedString("Indie"));

            gameCategoryPage.TopSellersButton.Click();
            SingleWebDriver.ScrollTo(0, 1000);
            SteamGame gameWithLowestDiscount = gameCategoryPage.SelectGameWithLowestDiscount();

            Logger.GetInstance().LogLine($"STEP: Game with lowest discount is got.");

            GamePage     gamePage = new GamePage();
            DiscountInfo discountInfoFromGamePage = gamePage.GetDiscountInfo();

            Assert.Multiple(() =>
            {
                Assert.AreEqual(gameWithLowestDiscount.DiscountInfo.Discount, discountInfoFromGamePage.Discount,
                                $"Discount from category page {gameWithLowestDiscount.DiscountInfo.Discount} is not equal to discount from game page.");
                Assert.AreEqual(gameWithLowestDiscount.DiscountInfo.OldPrice, discountInfoFromGamePage.OldPrice,
                                $"Old price from category page {gameWithLowestDiscount.DiscountInfo.OldPrice} is not equal to old price from game page.");
                Assert.AreEqual(gameWithLowestDiscount.DiscountInfo.NewPrice, discountInfoFromGamePage.NewPrice,
                                $"New price from category page {gameWithLowestDiscount.DiscountInfo.NewPrice} is not equal to new price from game page.");
            });
            Logger.GetInstance().LogLine($"STEP: Test complete.");
        }
Exemplo n.º 3
0
        public static List <SteamGame> GetDiscountedGames(string selector, string namesSelector)
        {
            IWebDriver driver = SingleWebDriver.GetInstance();

            IReadOnlyCollection <IWebElement> gotButtons   = driver.FindElements(By.XPath(selector));
            IReadOnlyCollection <IWebElement> gotNames     = driver.FindElements(By.XPath($"{selector}{namesSelector}"));
            IReadOnlyCollection <IWebElement> gotDiscounts = driver.FindElements(By.XPath($"{selector}{discountsSelector}"));
            IReadOnlyCollection <IWebElement> gotOldPrices = driver.FindElements(By.XPath($"{selector}{oldPricesSelector}"));
            IReadOnlyCollection <IWebElement> gotNewPrices = driver.FindElements(By.XPath($"{selector}{newPricesSelector}"));

            List <SteamGame> steamGames = new List <SteamGame>();
            int i = 0;

            foreach (IWebElement element in gotButtons)
            {
                string discount       = gotDiscounts.ElementAt(i).GetAttribute(innerText);
                string oldPrice       = gotOldPrices.ElementAt(i).GetAttribute(innerText);
                string newPrice       = gotNewPrices.ElementAt(i).GetAttribute(innerText);
                string name           = gotNames.ElementAt(i).GetAttribute(innerText);
                string uniqueSelector = $"{selector}/..//*[text()=\"{name}\"]";

                steamGames.Add(new SteamGame(discount, oldPrice, newPrice, By.XPath(uniqueSelector), name));
                i++;
            }
            return(steamGames);
        }
Exemplo n.º 4
0
 public BaseElement(By locator, string name)
 {
     this.Name    = name;
     this.driver  = SingleWebDriver.GetInstance();
     this.locator = locator;
 }
Exemplo n.º 5
0
 public PageObject()
 {
     this.driver = SingleWebDriver.GetInstance();
 }
Exemplo n.º 6
0
 public MainPage() : base()
 {
     SingleWebDriver.Open(SingleWebDriver.Configuration.GetParameter("SiteName"));
 }
Exemplo n.º 7
0
 public BaseForm()
 {
     this.driver = SingleWebDriver.GetInstance();
 }
Exemplo n.º 8
0
 public Select(By locator, string name) : base(locator, name)
 {
     elements = new SelectElement(SingleWebDriver.GetInstance().FindElement(locator));
 }
Exemplo n.º 9
0
 public void Setup()
 {
     SingleWebDriver.GetInstance();
     Configuration = SingleWebDriver.Configuration;
 }
Exemplo n.º 10
0
 public void TearDown()
 {
     SingleWebDriver.Quit();
     Logger.GetInstance().CreateLog(Configuration.OutputPath);
 }
Exemplo n.º 11
0
 public void Setup()
 {
     SingleWebDriver.GetInstance();
     Configuration = new TestConfiguration($"{Path.GetFullPath("..\\..\\..\\")}/config.json");
 }