Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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;
        }
Exemple #4
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);
        }
Exemple #5
0
 public PageOfPressReleases() : base(PressReleases.Locator, "Press Releases")
 {
     PageFactory.InitElements(WDriver.GetDriver(), this);
 }
Exemple #6
0
 public PageOfPressRelease() : base(PageOfPressRelease.ContactList.Locator, "Page of Press-Release")
 {
     PageFactory.InitElements(WDriver.GetDriver(), this);
 }