public void ThenICanSeeValueForId(string value, string elementId) { WithErrorLogging(() => { Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, elementId).Text); }); }
private static List <string> GetDropdownOptions(IWebDriver driver, string dropdownId) { return(new SelectElement(HtmlElementHelper.FindElementById(driver, dropdownId)) .Options .Select(opt => opt.Text) .ToList()); }
public void GivenIChooseToLogInWithDifferentAccount() { WithErrorLogging(() => { Browser.Navigate().GoToUrl($"{Settings.EnvironmentConfig.RootUriString}"); HtmlElementHelper.FindElementById(Browser, "otherTile").Click(); }); }
public void WhenIClickOn(string elementId) { WithErrorLogging(() => { var button = HtmlElementHelper.FindElementById(Browser, elementId); button.Click(); }); }
public void WhenIExpandSection(string sectionId) { WithErrorLogging(() => { var element = HtmlElementHelper.FindElementById(Browser, sectionId).FindElement(By.TagName("summary")); element.Click(); }); }
public void ThenICanSeeValueInTheOverviewSection(string value, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, sectionId).Text); }); }
public void ThenLinkIsPresentOnOverviewSection(string linkText, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var linkId = $"{sectionId}-{linkText}-link"; Assert.NotNull(HtmlElementHelper.FindElementById(Browser, linkId)); }); }
public void ThenICanNoValueForFieldInTheOverviewSection(string field, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var htmlId = $"{sectionId}-{field}"; Assert.Empty(HtmlElementHelper.FindElementById(Browser, htmlId).Text.Replace(" ", "")); }); }
public void ThenICanSeeValueForFieldInTheOverviewSection(string value, string field, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var htmlId = $"{sectionId}-{field}"; Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, htmlId).Text); }); }
public void ThenICanSeeCorrectTitlesForTable(string tableId) { WithErrorLogging(() => { var tableColumnTitles = HtmlElementHelper.FindElementById(Browser, tableId).FindElement(By.TagName("thead")) .FindElements(By.TagName("th")).Select(title => title.Text).ToArray(); var expectedTitles = GetExpectedColumnsTitlesForTable(tableId); Assert.Equal(tableColumnTitles.Select(titles => titles.Replace("\n", "").Replace("\r", "")), expectedTitles); }); }
public void WhenIRemoveFromInputList(string inputId) { WithErrorLogging(() => { var inputElement = HtmlElementHelper.FindElementById(Browser, inputId); inputElement.Click(); inputElement.SendKeys(Keys.Control + "a"); inputElement.SendKeys(Keys.Delete); inputElement.SendKeys("\t"); }); }
public void WhenISelectRadioOrCheckbox(string elementId) { WithErrorLogging(() => { var element = HtmlElementHelper.FindElementById(Browser, elementId); if (!element.Selected) { element.Click(); } }); }
public void ThenICanSeeTheCorrectLabelsForOverviewSection(string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var expectedLabels = GetExpectedLabels(section); var actualLabels = HtmlElementHelper.FindElementById(Browser, sectionId).FindElements(By.ClassName("notification-details-label")) .Select(label => label.Text).ToArray(); Assert.Equal(expectedLabels, actualLabels); }); }
public void WhenISelectFromInputList(string value, string inputListId) { WithErrorLogging(() => { var inputList = HtmlElementHelper.FindElementById(Browser, inputListId); inputList.Click(); inputList.SendKeys(Keys.Control + "a"); inputList.SendKeys(Keys.Delete); inputList.SendKeys(value); HtmlElementHelper.FindElementById(Browser, inputListId + "__option--0").Click(); inputList.SendKeys("\t"); }); }
public void ThenICanSeeTheWarningForId(string warningMessage, string warningId) { WithErrorLogging(() => { var warningElement = HtmlElementHelper.FindElementById(Browser, warningId); try { var wait = new WebDriverWait(Browser, Settings.ImplicitWait); wait.Until(ExpectedConditions.TextToBePresentInElement(warningElement, warningMessage)); } catch (WebDriverTimeoutException) { Assert.Contains(warningElement.Text, warningMessage); } }); }
public void WhenIEnterValueIntoFieldWithId(string value, string elementId) { WithErrorLogging(() => { // In some scenarios, inputs only become clickable after an asynchronous event. // Consequently, we add a wait here to ensure that the input is ready. Browser.WaitUntilElementIsClickable(By.Id(elementId), Settings.ImplicitWait); var element = HtmlElementHelper.FindElementById(Browser, elementId); element.Click(); element.SendKeys(Keys.Control + "a"); element.SendKeys(Keys.Delete); element.SendKeys(value + "\t"); if (!Settings.IsHeadless) { Thread.Sleep(1000); } }); }