public static void SetupTest() { Driver = WDriver.Instance; WDriver.NavigateTo(Config.StartUrl); WDriver.WindowMaximise(); BaseTest.SoftAssert = new SoftAssertions(); }
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); }
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)); }
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); }
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); }
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); }
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; }
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); }
public int CountOfPressReleasesOnList() { WDriver.WaitForIsVisible(By.XPath("//div[@role='tablist']")); return(this.TableOfPressReleases.FindElements(By.XPath("//div[@role='tablist']")).Count); }
public PageOfPressReleases() : base(PressReleases.Locator, "Press Releases") { PageFactory.InitElements(WDriver.GetDriver(), this); }
private void AssertIsOpen() { var label = new BaseElement(this.TitleLocator, this.Title); WDriver.WaitForIsVisible(this.TitleLocator); }
public PageOfPressRelease() : base(PageOfPressRelease.ContactList.Locator, "Page of Press-Release") { PageFactory.InitElements(WDriver.GetDriver(), this); }
public static void CleanUpTestClass() { BaseTest.SoftAssert.AssertAll(); SitePages.Close(); WDriver.Quit(); }