public ElementWaitUtils(IWebElement element, IWebDriver driver) { _element = element; _locator = WebElementUtils.GetLocator(_element); _driver = driver; _isTimeToWaitDefined = false; }
public void ThenIAssertThatTheCreatedAndModifiedDatepickersOnThePageAreReadonly(string entityName) { var entityOnEditPage = new GenericEntityEditPage(entityName, _contextConfiguration); Assert.True(WebElementUtils.IsReadonly(entityOnEditPage.CreateAtDatepickerField)); Assert.True(WebElementUtils.IsReadonly(entityOnEditPage.ModifiedAtDatepickerField)); }
public void ExpectAnElementToBePresentBy(SelectorPathType selector, string path, string expectedDate) { By elementBy = WebElementUtils.GetElementAsBy(selector, path); var elementText = _driver.FindElement(elementBy).Text; Assert.Equal(expectedDate, elementText); }
public void PresssKeyOnElementWith(KeyboardActionType keyName, SelectorPathType selector, string path) { var elementBy = WebElementUtils.GetElementAsBy(selector, path); var element = _driver.FindElement(elementBy); KeyboardUtils.EnterKeyToWebElement(element, keyName); }
public void ExpectElementByToContainText(SelectorPathType selector, string path, string expectedText) { By elementBy = WebElementUtils.GetElementAsBy(selector, path); var elementText = _driver.FindElement(elementBy).Text; Assert.Equal(expectedText, elementText); }
public void PasteToElement(SelectorPathType selector, string path) { var elementBy = WebElementUtils.GetElementAsBy(selector, path); var element = _driver.FindElement(elementBy); KeyboardUtils.PasteToWebElement(element); }
public void SelectAllInElement(SelectorPathType selector, string path) { var elementBy = WebElementUtils.GetElementAsBy(selector, path); var element = _driver.FindElement(elementBy); KeyboardUtils.SelectAllFromWebElement(element); }
public void IInsertValidBaseChoiceIntoElement(BaseChoiceType baseChoiceType, SelectorPathType selector, string path) { By elementBy = WebElementUtils.GetElementAsBy(selector, path); WaitUtils.elementState(_driverWait, elementBy, ElementState.EXISTS); switch (baseChoiceType) { case BaseChoiceType.INT: TypingUtils.TypeElement(_driver, elementBy, DataUtils.RandInt().ToString()); break; case BaseChoiceType.DOUBLE: TypingUtils.TypeElement(_driver, elementBy, DataUtils.RandDouble().ToString()); break; case BaseChoiceType.BOOL: TypingUtils.TypeElement(_driver, elementBy, DataUtils.RandBool().ToString()); break; case BaseChoiceType.EMAIL: TypingUtils.TypeElement(_driver, elementBy, DataUtils.RandEmail()); break; } }
public ElementWaitUtils(IWebElement element, IWebDriver driver, TimeSpan timeToWait) : this(element, driver) { _element = element; _locator = WebElementUtils.GetLocator(_element); _driver = driver; _isTimeToWaitDefined = true; _timeToWait = timeToWait; }
/// <summary>Uploads file to input element with type="file"</summary> /// <param name="filePath">File path</param> public void UploadFile(string filePath) { if (_element.GetAttribute("class").Split(' ').Contains("hidden")) { WebElementUtils.UnhideElement(_driver, _element); _element.SendKeys(filePath); WebElementUtils.HideElement(_driver, _element); return; } _element.SendKeys(filePath); }
/// <summary>Assert that element exists in page source. If element does not exist the method throws an exception.</summary> public void IsPresent() { _driver.VaftExt().TurnOffImplicitlyWait(); new WebDriverWait(_driver, GetExplicitWait()) { Message = "Element doesn't exist in page source. Locator: " + WebElementUtils.GetLocator(_element) } .Until(d => !_element.Equals(null)); _driver.VaftExt().TurnOnImplicitlyWait(); }
/// <summary>Assert that element is selected.</summary> public void IsNotSelected() { _driver.VaftExt().TurnOffImplicitlyWait(); new WebDriverWait(_driver, GetExplicitWait()) { Message = "Element should not be selected. Locator: " + WebElementUtils.GetLocator(_element) }.Until( d => !_element.Selected); _driver.VaftExt().TurnOnImplicitlyWait(); }
/// <summary>Assert text of element ignoring case.</summary> public void TextEquals(string text, string message) { try { StringAssert.AreEqualIgnoringCase(text, _element.Text, message); } catch (AssertionException) { WebElementUtils.HighlightElement(_driver, _element); throw; } }
/// <summary>Assert that element is displayed and enabled. If element is disabled the method throws an exception.</summary> public void IsEnabledAndDisplayed() { _driver.VaftExt().TurnOffImplicitlyWait(); new WebDriverWait(_driver, GetExplicitWait()) { Message = "Element is not enabled. Locator: " + WebElementUtils.GetLocator(_element) }.Until( d => _element.Displayed && _element.Enabled); _driver.VaftExt().TurnOnImplicitlyWait(); }
/// <summary> /// Assert that element is not visible, but exists in page source. If element is visible the method throws an /// exception. /// </summary> public void IsHidden() { _driver.VaftExt().TurnOffImplicitlyWait(); new WebDriverWait(_driver, GetExplicitWait()) { Message = "Element should be hidden. Locator: " + WebElementUtils.GetLocator(_element) }.Until( d => !_element.Displayed); _driver.VaftExt().TurnOnImplicitlyWait(); }
/// <summary> /// Assert that element is not displayed in Web page or doesn't exist in page source. If element is displayed the /// method throws an exception. /// </summary> public void IsNotDisplayed() { _driver.VaftExt().TurnOffImplicitlyWait(); new WebDriverWait(_driver, GetExplicitWait()) { Message = "Element should not be visible. Locator: " + WebElementUtils.GetLocator(_element) }.Until( VaftExpectedConditions.ElementIsNotVisible(_element)); _driver.VaftExt().TurnOnImplicitlyWait(); }
/// <summary>Assert element text starts with another text.</summary> public void TextStartsWith(string text, string message) { try { StringAssert.StartsWith(text, _element.Text, message); } catch (AssertionException) { WebElementUtils.HighlightElement(_driver, _element); throw; } }
/// <summary>Assert element text ends with another text.</summary> public void TextEndsWith(string text) { try { StringAssert.EndsWith(text, _element.Text); } catch (AssertionException) { WebElementUtils.HighlightElement(_driver, _element); throw; } }
/// <summary>Assert that element does not exist in page source. If element exists the method throws an exception.</summary> public bool IsNotPresent() { _driver.VaftExt().TurnOffImplicitlyWait(); var wait = new WebDriverWait(_driver, GetExplicitWait()) { Message = "Element should not exist in page source. Locator: " + WebElementUtils.GetLocator(_element) }.Until( VaftExpectedConditions.ElementDoesNotExist(_element)); _driver.VaftExt().TurnOnImplicitlyWait(); return(wait); }
public void IInsertValidStringBaseChoiceIntoElement(string baseChoiceType, int min, int max, SelectorPathType selector, string path) { var elementBy = WebElementUtils.GetElementAsBy(selector, path); WaitUtils.elementState(_driverWait, elementBy, ElementState.EXISTS); switch (baseChoiceType) { case "wordystring": TypingUtils.TypeElement(_driver, elementBy, DataUtils.RandString(min, max)); break; case "string": TypingUtils.TypeElement(_driver, elementBy, DataUtils.RandString(min, max)); break; } }
public void WaitForAnElementToBePresentBy(SelectorPathType selector, string path) { var elementBy = WebElementUtils.GetElementAsBy(selector, path); WaitUtils.elementState(_driverWait, elementBy, ElementState.EXISTS); }
public void ClickOnElementBy(SelectorPathType selector, string path) { var elementBy = WebElementUtils.GetElementAsBy(selector, path); MouseClickUtils.ClickOnElement(_driver, _driverWait, elementBy); }
public CheckboxUtils(IWebElement element) { _element = element; _locator = WebElementUtils.GetLocator(_element); }
public void ScrollToElementBy(SelectorPathType selector, string path) { By elementBy = WebElementUtils.GetElementAsBy(selector, path); ScrollingUtils.scrollToElement(_driver, elementBy); }
public void TypeElementBy(string text, SelectorPathType selector, string path) { By elementBy = WebElementUtils.GetElementAsBy(selector, path); TypingUtils.TypeElement(_driver, elementBy, text); }
public void ExpectAnElementToBePresentBy(SelectorPathType selector, string path) { By elementBy = WebElementUtils.GetElementAsBy(selector, path); Assert.True(_driver.FindElement(elementBy).Displayed); }
public void WaitForAnElementToNotBeVisibleBy(SelectorPathType selector, string path) { var elementBy = WebElementUtils.GetElementAsBy(selector, path); WaitUtils.elementState(_driverWait, elementBy, ElementState.NOT_VISIBLE); }