public void AddTitle(string title) { var titleElement = _browser.GetDriver().FindElement(By.Id("Title")); Assert.IsNotNull(titleElement, "Can't find title edit-box at the page."); titleElement.Click(); titleElement.Clear(); titleElement.SendKeys(title); }
public void SetPasswordText(string password) { var passwordElement = _browser.GetDriver().FindElement(By.Id("Password")); Assert.IsNotNull(passwordElement, "Can't find password at the page."); passwordElement.Click(); passwordElement.Clear(); passwordElement.SendKeys(password); }
public void CheckThatHeaderContainsText(string hederNumber, string text) { var headers = _browser.GetDriver().FindElements(By.TagName(hederNumber)); var creatMessageHeader = headers.SingleOrDefault(element => element.Text.Equals(text, StringComparison.OrdinalIgnoreCase)); if (creatMessageHeader == null) { var existedLinks = string.Join(", ", headers.Select(tag => $"[Tag: {tag.TagName}, Text: {tag.Text}]")); Assert.Fail($"Can't find [{text}] link in page. Existed links is: [{existedLinks}]"); } }
public void CheckThatTextShownForNewMessage(string text) { var paragraphs = _browser.GetDriver().FindElements(By.TagName("p")); var creatMessageHeader = paragraphs.SingleOrDefault(element => element.Text.Equals(text, StringComparison.OrdinalIgnoreCase)); if (creatMessageHeader == null) { var existedLinks = string.Join(", ", paragraphs.Select(tag => $"[Tag: {tag.TagName}, Text: {tag.Text}]")); Assert.Fail($"Can't find [{text}] in paragraph in page. Existed paragraphs is: [{existedLinks}]"); } }
public void ClickOnButtonWithValue(string valueText) { IList <IWebElement> links = _browser.GetDriver().FindElements(By.ClassName("btn")); var creatMessageLink = links.SingleOrDefault(element => element.GetProperty("value").Equals(valueText, StringComparison.OrdinalIgnoreCase)); if (creatMessageLink == null) { var existedLinks = string.Join(", ", links.Select(link => $"Tag: {link.TagName}, Value: {link.GetProperty("value")}")); Assert.Fail($"Can't find [{valueText}] button in page. Existed links is: [{existedLinks}]"); } creatMessageLink.Click(); }
public void ClickOnButtonWithText(string linkText) { IList <IWebElement> links = _browser.GetDriver().FindElements(By.TagName("button")); var creatMessageLink = links.SingleOrDefault(element => element.Text.Equals(linkText, StringComparison.OrdinalIgnoreCase)); if (creatMessageLink == null) { var existedLinks = string.Join(", ", links.Select(link => $"Tag: {link.TagName}, Text: {link.Text}")); Assert.Fail($"Can't find [{linkText}] link in page. Existed links is: [{existedLinks}]"); } creatMessageLink.Click(); }
private IWebElement FindHeaderButtonWithText(string linkText) { var menus = _browser.GetDriver().FindElements(By.ClassName("navbar-nav")); IWebElement listItemWithExpectedText = null; foreach (var menu in menus) { if (menu == null) { Assert.Fail("Can't find menu element with links"); } IList <IWebElement> listItemElements = menu.FindElements(By.TagName("li")); listItemWithExpectedText = listItemElements.SingleOrDefault(element => { var embededLinks = element.FindElements(By.TagName("a")); var embededLink = embededLinks.SingleOrDefault(); if (embededLink == null) { Assert.Fail("Can't find list item with embed link"); } else { return(embededLink.Text.Equals(linkText, StringComparison.OrdinalIgnoreCase)); } return(false); } ); if (listItemWithExpectedText != null) { break; } } if (listItemWithExpectedText == null) { Assert.Fail($"Can't find header button with text [{linkText}] in page."); } return(listItemWithExpectedText); }
private IWebElement FindIsLinkWithText(string linkText) { IList <IWebElement> links = _browser.GetDriver().FindElements(By.TagName("a")); return(links.SingleOrDefault(element => element.Text.Equals(linkText, StringComparison.OrdinalIgnoreCase))); }
public void ThenUserLoggedIn() { const string helloMessage = "Hello Denis Kosolapov!"; IList <IWebElement> links = _browser.GetDriver().FindElements(By.TagName("a")); var linkWithUserName = links.SingleOrDefault(element => element.Text.Equals(helloMessage, StringComparison.OrdinalIgnoreCase)); Assert.IsNotNull(linkWithUserName, $"Can't find [{helloMessage}] link in page."); }