Example #1
0
 public static void SetupTest()
 {
     Driver = WDriver.Instance;
     WDriver.NavigateTo(Config.StartUrl);
     WDriver.WindowMaximise();
     BaseTest.SoftAssert = new SoftAssertions();
 }
Example #2
0
        public PageOfPressReleases ClickLoadMore()
        {
            for (int i = 0; i <= Config.CountOfClickMoreLoad - 1; i++)
            {
                WDriver.WaitForIsVisible(By.XPath("//button[contains(@class, 'load-more-button')]"));
                this.LoadMore.Click();
            }

            return(this);
        }
Example #3
0
        public static BasePage NavigatePageTo(BaseElement pointMenuToHover, BaseElement pointMenuToClick, SitePages.Pages page)
        {
            WDriver.HoverOnElement(pointMenuToHover);

            var elementToClick = pointMenuToClick.FindElement(pointMenuToClick.Locator);

            WDriver.SetBackgroundColorForElement(elementToClick);
            pointMenuToClick.Click();

            return(SitePages.GetPage(page));
        }
Example #4
0
        private List <PressRelease> PressReleasesWithId()
        {
            var pressReleases = new List <PressRelease>();

            if (WDriver.GetDriver().FindElements(By.XPath(PageOfPressReleases.XpathToLinkOfPageOnPressRelease)).Count != 0)
            {
                var allTabWithPressReleases = WDriver.GetDriver().FindElements(By.XPath(PageOfPressReleases.XpathToLinkOfPageOnPressRelease));

                foreach (var elementWithId in allTabWithPressReleases)
                {
                    pressReleases.Add(new PressRelease(int.Parse(elementWithId.GetAttribute(PageOfPressReleases.AttributeHref)
                                                                 .Replace(
                                                                     Config.PatternToUrlOnPageOfPressRelease,
                                                                     string.Empty))));
                }
            }

            return(pressReleases);
        }
Example #5
0
        public List <PressRelease> PressReleasesWithSizeOfElement(string xpath, string attribute, SizeOfFile fileType)
        {
            var pressRelease = this.PressReleasesWithId();

            var pressReleasesTab = WDriver.GetDriver().FindElements(By.XPath("//div[@role='tablist']")).ToList();

            for (int i = 0; i < pressReleasesTab.Count; i++)
            {
                var elementsWithUrl = pressReleasesTab.ElementAt(i).FindElements(By.XPath(string.Format(xpath, i + 1)));

                if (elementsWithUrl.Count != 0)
                {
                    var url = elementsWithUrl.First().GetAttribute(attribute);

                    pressRelease.ElementAt(i).WithSizeOfFile(fileType, url);
                }
            }

            return(pressRelease);
        }
Example #6
0
        public List <PressRelease> PressReleasesWithTitle()
        {
            var pressReleases = this.PressReleasesWithId();

            int skipCount = 0;

            var by = By.XPath(PageOfPressReleases.XpathToTitleOfPressRelease);

            foreach (var pressRelease in pressReleases)
            {
                var title = WDriver.GetListValueWithSkipAndTakeElements(by, skipCount, 2);

                skipCount += 2;

                Helper.PostHandlingForDateOfPressReleases(title, false);

                pressRelease.WithTitle(title.ElementAt(0), title.ElementAt(1));
            }

            return(pressReleases);
        }
Example #7
0
        public void WhenIGetTitleOfPress_ReleaseOnThePage()
        {
            var elementsWithLink = page.GetElementsOfLinkToPageOfPressRelease();

            var titlesOfPressReleasesOnPage = new List <string>();

            foreach (var link in elementsWithLink)
            {
                var tab = WDriver.OpenLinkInNewTab(link);
                var pageOfPressRelease = new PageOfPressRelease();
                titlesOfPressReleasesOnPage.AddRange(pageOfPressRelease.GetTitleOfPressReleaseOnPage());

                tab.Close();

                WDriver.GetDriver().SwitchTo().Window(WDriver.GetDriver().WindowHandles.First());
            }

            Helper.PostHandlingForDateOfPressReleases(titlesOfPressReleasesOnPage, true);
            Helper.JoinStringsInListByPair(titlesOfPressReleasesOnPage);

            ScenarioContext.Current["TitlesOfPressReleasesOnPage"] = titlesOfPressReleasesOnPage;
        }
Example #8
0
        public List <PressRelease> FilterPressReleasesByDate(string dateFrom, string dateTo)
        {
            var pressReleases = new List <PressRelease>();

            WDriver.SetValueByScript("Id", this.calendarFromId, dateFrom);
            WDriver.SetValueByScript("Id", this.calendarToId, dateTo);

            // Sometimes test failed because of button isn't clickable.
            WDriver.GetDriver().ExecuteScript("scroll(250, 0)");
            this.FilterButtonApply.Click();

            // Need handling of case when search found 0 items. There aren't press-releases.
            // For this to wait loading of page and to count found items.
            WDriver.WaitForIsVisible(By.XPath("//div[contains(@class,'text-right')]"));

            if (PageOfPressReleases.TitleOfPressReleases.FindElements(PageOfPressReleases.TitleOfPressReleases.Locator).Count != 0)
            {
                // Wait loading of DOM with new elements.
                PageOfPressReleases.TitleOfPressReleases.IsVisible();
                return(this.PressReleasesWithDate());
            }

            return(pressReleases);
        }
Example #9
0
        public int CountOfPressReleasesOnList()
        {
            WDriver.WaitForIsVisible(By.XPath("//div[@role='tablist']"));

            return(this.TableOfPressReleases.FindElements(By.XPath("//div[@role='tablist']")).Count);
        }
Example #10
0
 public PageOfPressReleases() : base(PressReleases.Locator, "Press Releases")
 {
     PageFactory.InitElements(WDriver.GetDriver(), this);
 }
Example #11
0
        private void AssertIsOpen()
        {
            var label = new BaseElement(this.TitleLocator, this.Title);

            WDriver.WaitForIsVisible(this.TitleLocator);
        }
Example #12
0
 public PageOfPressRelease() : base(PageOfPressRelease.ContactList.Locator, "Page of Press-Release")
 {
     PageFactory.InitElements(WDriver.GetDriver(), this);
 }
Example #13
0
 public static void CleanUpTestClass()
 {
     BaseTest.SoftAssert.AssertAll();
     SitePages.Close();
     WDriver.Quit();
 }