/// <summary> /// Gets the tab body of a tab. /// </summary> /// <param name="tabName">Name of the tab.</param> /// <param name="stringComparison">The string comparison.</param> /// <returns></returns> /// <exception cref="NoSuchElementException"></exception> public virtual IWebElement GetTabBody(string tabName, StringComparison stringComparison = StringComparison.Ordinal) { var headerElement = GetTabHeaderElements() .FirstOrDefault( e => String.Equals( tabName, e.TextHelper().InnerText, stringComparison)); if (headerElement == null) { throw new NoSuchElementException(); } var sel = headerElement.GetAttribute("href"); var bodyElement = WrappedElement.FindElement(By.CssSelector(sel)); if (bodyElement == null) { throw new NoSuchElementException(); } return(bodyElement); }
/// <summary> /// Gets the name of the active tab. /// </summary> /// <returns></returns> public virtual string GetActiveTabName() { return(WrappedElement .FindElement(configuration.ActiveTabHeaderNameSelector) .TextHelper() .InnerText); }
/// <summary> /// Gets the direction float menu will open relative to the CENTER of /// this WrappedElement. /// </summary> /// <returns></returns> private (int X, int Y) GetDirectionFloatMenuWillOpen() { var vector = (X : 0, Y : 0); var caretElement = WrappedElement.FindElement( By.CssSelector(".mce-caret")); var css = new CssColor( caretElement.GetCssValue( "border-left-color")); // If the border-left-color is transparent, then it opens down. if (css.Color.ToArgb() == 0) { // Opens below. vector.X = 0; vector.Y = WrappedElement.Size.Height; } else { // Opens to the right if enough space. Need to check if there // is enough space. TODO: identify way to check the offset of // the container due to lack of space. vector.X = WrappedElement.Size.Width; vector.Y = 0; } return(vector); }
public string GetFlagType() { WrappedElement = WrappedElement.FindElement(_byLanguageLink); string flag = WrappedElement.FindElement(By.CssSelector("img")).GetAttribute("alt"); return(flag.Equals("На русском") ? "Русский" : flag); }
/// <summary> /// Navigates to the product page. /// </summary> /// <returns></returns> public virtual IBaseProductPage GoToProductPage() { var link = WrappedElement.FindElement(nameSelector); link.Click(); return(pageObjectFactory.PreparePage <IBaseProductPage>()); }
/// <summary> /// Finds the first <see cref="NgWebElement" /> using the given mechanism. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns>The first matching <see cref="NgWebElement" /> on the current context.</returns> /// <exception cref="NoSuchElementException">If no element matches the criteria.</exception> public NgWebElement FindElement(By by) { if (by is JavaScriptBy scriptBy) { scriptBy.AdditionalScriptArguments = new object[] { NgDriver.RootElement, WrappedElement } } ; NgDriver.WaitForAngular(); return(new NgWebElement(NgDriver, WrappedElement.FindElement(by))); }
public List <IWebElement> GetRow(int rowNumber) { if (rowNumber == 1) { if (WrappedElement.ElementExists(By.CssSelector("th"))) { return(WrappedElement.FindElement(By.CssSelector(string.Format("tr:nth-child({0})", rowNumber))).FindElements(By.CssSelector("th")).ToList()); } } return(WrappedElement.FindElement(By.CssSelector(string.Format("tr:nth-child({0})", rowNumber))).FindElements(By.CssSelector("td")).ToList()); }
public IWebElement GetCell(int columnNumber, int rowNumber) { if (rowNumber == 1) { if (WrappedElement.ElementExists(By.CssSelector("th"))) { return(WrappedElement.FindElement(By.CssSelector(string.Format("tr:nth-child({0}) th:nth-child({1})", rowNumber, columnNumber)))); } } return(WrappedElement.FindElement(By.CssSelector(string.Format("tr:nth-child({0}) td:nth-child({1})", rowNumber, columnNumber)))); }
private AddressModel GetAddressFromListElement(IWebElement listElement) { var fullNameSelector = By.CssSelector("tr:nth-child(1) td:nth-child(2)"); var emailSelector = By.CssSelector("tr:nth-child(2) td:nth-child(2)"); var phoneSelector = By.CssSelector("tr:nth-child(3) td:nth-child(2)"); var faxSelector = By.CssSelector("tr:nth-child(4) td:nth-child(2)"); var companySelector = By.CssSelector("tr:nth-child(5) td:nth-child(2)"); var address1Selector = By.CssSelector("tr:nth-child(6) td:nth-child(2)"); var address2Selector = By.CssSelector("tr:nth-child(7) td:nth-child(2)"); var citySelector = By.CssSelector("tr:nth-child(8) td:nth-child(2)"); var stateProvinceSelector = By.CssSelector("tr:nth-child(9) td:nth-child(2)"); var zipSelector = By.CssSelector("tr:nth-child(10) td:nth-child(2)"); var countrySelector = By.CssSelector("tr:nth-child(11) td:nth-child(2)"); string GetTextFor(By selector) { return(WrappedElement.FindElement(selector) .TextHelper() .InnerText); } var fullName = GetTextFor(fullNameSelector); var splitName = fullName.Split( separator: new[] { ' ' }, count: 2, options: StringSplitOptions.RemoveEmptyEntries); var fName = splitName[0]; var lName = splitName.Length > 1 ? splitName[1] : null; var model = new AddressModel { Address1 = GetTextFor(address1Selector), Address2 = GetTextFor(address2Selector), City = GetTextFor(citySelector), Company = GetTextFor(companySelector), Country = GetTextFor(countrySelector), Email = GetTextFor(emailSelector), FaxNumber = GetTextFor(faxSelector), FirstName = fName, LastName = lName, PhoneNumber = GetTextFor(phoneSelector), StateProvince = GetTextFor(stateProvinceSelector), ZipPostalCode = GetTextFor(zipSelector) }; return(model); }
private IWebElement FindSortBy(By by) // for buttons with long names (example - Russian language) { // or for small browser's window IWebElement sortBy; if (WrappedElement.FindElement(by).Displayed) { sortBy = WrappedElement.FindElement(by); } else { WrappedElement.FindElement(_byButton).Click(); Wait.Until(ExpectedConditions.ElementIsVisible(by)); sortBy = WrappedElement.FindElement(by); } return(sortBy); }
internal SearchForm FillForm(Table table) //for specflow table { var header = table.Header; var row = table.Rows.First(); if (header.Contains("enter location")) { WrappedElement.FindElement(_byDestinationField).SendKeys(row["enter location"]); } if (header.Contains("select location") && !string.IsNullOrWhiteSpace(row["select location"])) { DroopedListHandling(row["select location"]); } if (header.Contains("checkin")) { OpenArrivalCalendar(true).SelectDate(Int32.Parse(row["checkin"])); // date here is the numbers of a days from today } if (header.Contains("checkout")) { OpenDepartureCalendar().SelectDate(Int32.Parse(row["checkout"])); // date here is the numbers of a days from today } // далее можно добавить обработку полей для всех элементов формы return(this); }
public LanguageMenu OpenLanguageMenu() { WrappedElement.FindElement(_byLanguageLink).Click(); return(new LanguageMenu(Wait.Until(ExpectedConditions.ElementIsVisible(_byLanguageMenu)))); }
public UpWebElement FindElement(By by) { UpDriver.WaitForPageReady(); Log.GetLogger().Info($"Finding element by locator:[{by}]"); return(new UpWebElement(UpDriver, WrappedElement.FindElement(by), by)); }
private IWebElement GetNotProxiedInputElement() { // Cannot get something from WebElementProxy class since it's 'internal' return(WrappedElement.FindElement(By.XPath("."))); }
public void Submit() { WrappedElement.FindElement(_bySubmit).Click(); }
protected IWebElement GetMonthYearElement(string monthYear) => WrappedElement.FindElement(By.XPath($".//table[contains(., '{monthYear}')]"));
/// <summary> /// Clicks outside Kendo input element to hide the list box. /// </summary> public void CollapseListBox() { WrappedElement.FindElement(By.XPath("./parent::*")).Click(); Thread.Sleep(1000); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> public IWebElement GetItem(string name) { return(WrappedElement.FindElement(By.CssSelector(string.Format("li[text='{0}']", name)))); }
protected IWebElement LanguageFor(string lang) => WrappedElement.FindElement(By.XPath($".//a[contains(., '{lang}')]"));
public ProfileMenu OpenProfileMenu() { WrappedElement.FindElement(_byProfileLink).Click(); return(new ProfileMenu(Wait.Until(ExpectedConditions.ElementIsVisible(_byProfileMenu)))); }
public LoginForm OpenLoginForm() { WrappedElement.FindElement(_byLoginLink).Click(); return(new LoginForm(Wait.Until(ExpectedConditions.ElementIsVisible(_byLoginForm)))); }
/// <summary> /// Finds the first <see cref="T:OpenQA.Selenium.IWebElement" /> using the given method. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns> /// The first matching <see cref="T:OpenQA.Selenium.IWebElement" /> on the current context. /// </returns> public IWebElement FindElement(By by) { return(WrappedElement.FindElement(by)); }
public CurrencyMenu OpenCurrencyMenu() { WrappedElement.FindElement(_byCurrencyLink).Click(); return(new CurrencyMenu(Wait.Until(ExpectedConditions.ElementIsVisible(_byCurrencyMenu)))); }