public bool IsPasswordFormPresentOnTheScreen() { return(IsElementVisible(By.CssSelector("input[name='passCode']"))); }
public int GetGroupsCount() { return(driver.FindElements(By.CssSelector("span.group")).Count); }
// Explicit Wait for invisibility of an elements depending on time and method public static void ExplicitWaitInvisible(this IWebDriver driver, int time, string method, string locator) { if (method == "Id") { new WebDriverWait(driver, TimeSpan.FromSeconds(time)).Until(ExpectedConditions.InvisibilityOfElementLocated((By.Id(locator)))); } else if (method == "ClassName") { new WebDriverWait(driver, TimeSpan.FromSeconds(time)).Until(ExpectedConditions.InvisibilityOfElementLocated((By.ClassName(locator)))); } else if (method == "XPath") { new WebDriverWait(driver, TimeSpan.FromSeconds(time)).Until(ExpectedConditions.InvisibilityOfElementLocated((By.XPath(locator)))); } else if (method == "Name") { new WebDriverWait(driver, TimeSpan.FromSeconds(time)).Until(ExpectedConditions.InvisibilityOfElementLocated((By.Name(locator)))); } else if (method == "CssSelector") { new WebDriverWait(driver, TimeSpan.FromSeconds(time)).Until(ExpectedConditions.InvisibilityOfElementLocated((By.CssSelector(locator)))); } }
public List <IWebElement> GetProductsItemTotal() { var listOfElements = this.TransactionTableRoot.FindElements(By.CssSelector(".wpsc-purchase-log-transaction-results > tbody > tr > td:first-of-type + td + td + td")); return(listOfElements.ToList <IWebElement>()); }
public virtual void ActionsAvailableOnEmptyCollections() { GeminiUrl("object?i1=View&r1=1&o1=___1.SalesOrderHeader--70589"); WaitForTextEquals(".collection", 1, "Reasons:\r\nEmpty"); Click(WaitForCssNo(".icon.list", 1)); //Add new sales reason; remove sales reasons wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[1].FindElements(By.CssSelector("nof-action-bar nof-action input"))[0].GetAttribute("value") == "Add New Sales Reason"); wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[1].FindElements(By.CssSelector("nof-action-bar nof-action input"))[1].GetAttribute("value") == "Remove Sales Reasons"); Click(WaitForCss(".icon.summary")); WaitUntilElementDoesNotExist(".collection .actions"); }
public ConfirmRequiredSchoolIntakeDialog ClickSave() { Action clickAction = () => _saveButton.Click(); ClickWhenElementIsReady(clickAction, By.CssSelector("[data-automation-id = 'well_know_action_save']")); return new ConfirmRequiredSchoolIntakeDialog(); }
public void ClickOnAddNewAdmissionGroupButton() { Action clickAction = () => _addAdmissionGroupButton.Click(); ClickWhenElementIsReady(clickAction, By.CssSelector("[data-automation-id='add_admission_group_button']")); }
private string Error(string selector) { var label = browser.FindElementByCssSelector(selector).FindElement(By.XPath("..")).FindElement(By.CssSelector("label.error")); if (label == null) { return(""); } return(label.Text); }
public void CheckInTeacher_Settings_CheckSSO_Mobile() { TestBaseWebDriver test = base.TestContainer[Gallio.Framework.TestContext.CurrentContext.Test.Name]; TestLog.WriteLine("Log in Teacher project"); test.CheckIn.LoginMobileWebDriver(); TestLog.WriteLine("Check SSO icon displays well"); test.GeneralMethods.WaitForElement(By.CssSelector("[ng-controller=\"LauncherController\"]")); TestLog.WriteLine("Click SSO icon"); test.Driver.FindElementByCssSelector("[class=\"nav-bar-block\"][nav-bar=\"active\"]").FindElement(By.CssSelector("[class=\"NineGrid-img\"]")).Click(); test.GeneralMethods.WaitForElement(By.CssSelector("[class=\"NineGrid-apps-list\"]")); test.GeneralMethods.WaitForElement(By.CssSelector("[class=\"NineGrid-img NineGrid-img--prom\"]")); test.Driver.FindElementByCssSelector("[class=\"nav-bar-block\"][nav-bar=\"active\"]").FindElement(By.CssSelector("[class=\"NineGrid-img NineGrid-img--prom\"]")).Click(); //Logout test.CheckIn.LogoutWebDriver(); }
public void ShoppingBagARC() { // Login driver.Navigate().GoToUrl(baseURL + "/home.jsp"); driver.Manage().Window.Maximize(); for (int second = 0; ; second++) { if (second >= 60) { Assert.Fail("timeout"); } try { if (IsElementPresent(By.Id("home"))) { break; } } catch (Exception) { } Thread.Sleep(3000); } //driver.FindElement(By.CssSelector("#css_apl > a > img")).Click(); //Thread.Sleep(3000); //Order 1 driver.FindElement(By.LinkText("PETITES")).Click(); Thread.Sleep(3000); driver.FindElement(By.Id("keyword")).SendKeys("shoes" + Keys.Enter); Thread.Sleep(3000); driver.FindElement(By.Id("4074")).Click(); Thread.Sleep(3000); driver.FindElement(By.Id("size37")).Click(); Thread.Sleep(3000); driver.FindElement(By.XPath("//img[@alt='Navy']")).Click(); Thread.Sleep(3000); driver.FindElement(By.CssSelector("input.obutton.pie")).Click(); Thread.Sleep(10000); driver.FindElement(By.LinkText("Close")).Click(); Thread.Sleep(4000); //Order2 driver.FindElement(By.LinkText("PETITES")).Click(); Thread.Sleep(3000); driver.FindElement(By.Id("keyword")).SendKeys("shoes" + Keys.Enter); Thread.Sleep(3000); driver.FindElement(By.Id("10285")).Click(); Thread.Sleep(3000); driver.FindElement(By.Id("size75")).Click(); Thread.Sleep(3000); driver.FindElement(By.Id("thirdW")).Click(); Thread.Sleep(3000); driver.FindElement(By.XPath("//img[@alt='Lavender']")).Click(); Thread.Sleep(4000); driver.FindElement(By.CssSelector("input.obutton.pie")).Click(); Thread.Sleep(4000); driver.FindElement(By.LinkText("Close")).Click(); Thread.Sleep(6000); driver.FindElement(By.CssSelector("#widget-but-ucart > a")).Click(); Thread.Sleep(4000); driver.FindElement(By.CssSelector("#shopping-cart-items > tbody > tr:nth-child(15) > td > a:nth-child(2)")).Click(); Thread.Sleep(4000); //Checkout Button and Checkout driver.FindElement(By.XPath("//*[@id='estimatedOrderTotal']/div[1]/input[2]")).Click(); Thread.Sleep(4000); driver.FindElement(By.Id("userName")).Clear(); driver.FindElement(By.Id("userName")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("password")).Clear(); driver.FindElement(By.Id("password")).SendKeys("Asher2016"); Thread.Sleep(4000); driver.FindElement(By.Id("jsAjaxSignIn")).Click(); Thread.Sleep(8000); driver.FindElement(By.XPath("//input[@value='Continue']")).Click(); Thread.Sleep(5000); driver.FindElement(By.XPath("//input[@value='Continue']")).Click(); Thread.Sleep(5000); // MultiTab(5); // My own creation //Thread.Sleep(5000); //Security Code driver.FindElement(By.Id("ccSecurityCode")).SendKeys("321"); Thread.Sleep(4000); //Place Order driver.FindElement(By.XPath("//input[@value='Continue']")).Click(); Thread.Sleep(4000); driver.FindElement(By.XPath("//input[@value='Place Order']")).Click(); Thread.Sleep(5000); ////driver.FindElement(By.Id("widget-but-ucart")).Click(); //Thread.Sleep(3000); ////driver.FindElement(By.LinkText("Tops")).Click(); ////Thread.Sleep(3000); ////driver.FindElement(By.LinkText("Mocks & Turtlenecks")).Click(); ////Thread.Sleep(3000); //driver.FindElement(By.LinkText("Close")).Click(); //Thread.Sleep(3000); //driver.FindElement(By.Id("widget-but-ucart")).Click(); }
public void LoginGenerico(string user, string pass, string centoCusto, string pathCentroCusto, string msgErro, string empresa, string site) { try { ChromeOptions chromeoptions = new ChromeOptions(); chromeoptions.AddArguments("headless"); driver = new ChromeDriver(chromeoptions); //driver = new ChromeDriver(); driver.Manage().Window.Maximize(); Thread.Sleep(5000); driver.Navigate().GoToUrl("https://cn.br-petrobras.com.br/login/login.jsf"); Thread.Sleep(10000); driver.Navigate().Refresh(); Thread.Sleep(10000); driver.FindElement(By.Id("usuario")).SendKeys(user); Thread.Sleep(1000); driver.FindElement(By.Id("senha")).SendKeys(pass); Thread.Sleep(1000); driver.FindElement(By.Id("j_id1377415186_1_790d5166")).Click(); Thread.Sleep(5000); driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='HOME'])[1]/following::a[1]")).Click(); Thread.Sleep(1000); driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='Rascunhos dos Pedidos'])[1]/following::a[1]")).Click(); Thread.Sleep(4000); driver.FindElement(By.XPath(pathCentroCusto)).Click(); Thread.Sleep(1000); driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='CNPJ:'])[1]/following::input[3]")).Click(); Thread.Sleep(1000); driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='HOME'])[1]/following::a[1]")).Click(); Thread.Sleep(1000); driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='Agendar'])[1]/preceding::a[1]")).Click(); Thread.Sleep(1000); var elemento = driver.FindElement(By.ClassName("dv-formulario-tabela-produtos")); var linhas = elemento.FindElements(By.ClassName("linha-item-")); List<Produto> precos = new List<Produto>(); foreach (var linha in linhas) { string numero = linha.FindElement(By.ClassName("valor-numerico")).Text; string produto = linha.FindElement(By.CssSelector("td > span")).Text; precos.Add(new Produto(produto, numero, site, empresa, centoCusto)); } System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List<Produto>)); var path = $@"C:\Diretorio{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}.xml"; System.IO.FileStream file = System.IO.File.Create(path); writer.Serialize(file, precos); file.Close(); driver.Quit(); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.Message == "O tempo limite da operação foi atingido") { msgErro = "A página não pôde ser carregada por que o servidor não deu retorno."; } System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(TratamentoDeErro)); var path = $@"C:\Diretorio{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}.xml"; System.IO.FileStream file = System.IO.File.Create(path); writer.Serialize(file, new TratamentoDeErro(msgErro, empresa, centoCusto)); file.Close(); driver.Quit(); } }
public static IWebElement GetInvalidEmailInput() { return(Driver.Instance.WebDriver.FindElement(By.CssSelector(emailInputErrorPath))); }
protected void clickOnElement(string cssSelector) { browser.FindElement(By.CssSelector(cssSelector)).Click(); }
protected List <IWebElement> GetPictures() { return(browser.FindElements(By.CssSelector(".v1Nh3.kIKUG._bz0w")).ToList()); }
public RegisterPage(IWebDriver driver) { Driver = driver; Waits.WaitForElement(driver, By.CssSelector("input[id='EmailAddress']")); PageFactory.InitElements(driver, this); }
public void ConnectToBasicAuthByURL() { Driver.Navigate().GoToUrl("http://*****:*****@the-internet.herokuapp.com/basic_auth"); string PageMessage = Driver.FindElement(By.CssSelector("p")).Text; Assert.That(PageMessage.Contains("Congratulations!")); }
private IWebElement FindElement(string search, string by, TimeSpan timeout) { IWebElement element = null; var searchBy = Enum.GetValues(typeof(ElementSearchBy)) .Cast <ElementSearchBy?>() .FirstOrDefault(e => e.ToString().Equals(by, StringComparison.OrdinalIgnoreCase)); try { switch (searchBy) { case null: throw new ArgumentException("Value for argument 'By' was not recognized"); case ElementSearchBy.Id: search = search.StartsWith("#") ? search.TrimStart(new char[] { '#' }) : search; element = new WebDriverWait(webDriver, timeout).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.Id(search))); break; case ElementSearchBy.Class: element = new WebDriverWait(webDriver, timeout).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.ClassName(search))); break; case ElementSearchBy.CssSelector: element = new WebDriverWait(webDriver, timeout).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.CssSelector(search))); break; case ElementSearchBy.Tag: element = new WebDriverWait(webDriver, timeout).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.TagName(search))); break; case ElementSearchBy.Xpath: element = new WebDriverWait(webDriver, timeout).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.XPath(search))); break; case ElementSearchBy.Name: element = new WebDriverWait(webDriver, timeout).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.Name(search))); break; case ElementSearchBy.Query: element = new WebDriverWait(webDriver, timeout).Until(CustomExpectedConditions.ElementExistsByJavaScript(search)); break; case ElementSearchBy.Jquery: element = new WebDriverWait(webDriver, timeout).Until(CustomExpectedConditions.ElementExistsByJquery(search)); break; } } catch (ArgumentException) { throw; } catch { string errorMessage = $"Timeout occured while waiting for element. Search phrase: '{search}', by: '{by}' {(webDriver is InternetExplorerDriver ? ". It might be necessary to disable protection mode and lower security level in Internet Explorer." : string.Empty)}"; throw new TimeoutException(errorMessage); } return(element); }
List <BetPawaOdds> GetOdds(ReadOnlyCollection <IWebElement> selectsnodds) { var lstBets = new List <BetPawaOdds>(); for (int i = 0; i < selectsnodds.Count; i++) { var container = selectsnodds[i]; var mainType = container.FindElement(By.TagName("h3")).Text; var subcontainers = container.FindElements(By.ClassName("events-sub-container")); string selectionType = ""; for (int j = 0; j < subcontainers.Count; j++) { var bsubCont = subcontainers[j]; string sType; try { sType = bsubCont.FindElement(By.TagName("h4")).Text; } catch (NoSuchElementException) { sType = null; } if (string.IsNullOrEmpty(sType)) { sType = selectionType; } else { selectionType = sType; } var listBetHtml = bsubCont.FindElements(By.CssSelector(".event-bet")); for (int k = 0; k < listBetHtml.Count; k++) { var html = listBetHtml[k]; string slct = null; string odd = null; try { slct = html.FindElement(By.ClassName("event-selection")).Text; odd = html.FindElement(By.ClassName("event-odds")).Text; } catch (Exception) { continue; } if (!(string.IsNullOrEmpty(slct) || string.IsNullOrEmpty(odd))) { lstBets.Add(new BetPawaOdds { MainType = mainType, Type = sType, Selection = slct, Value = odd }); } } } } //for (int i = 0; i < selects.Count; i++) //{ // lstBets.Add(new BetPawaOdds { Selection = selects[i].Text, Value = odds[i].Text }); //} return(lstBets); }
public void ClickSaveWithNoConfirmation() { Action clickAction = () => _saveButton.Click(); ClickWhenElementIsReady(clickAction, By.CssSelector("[data-automation-id = 'well_know_action_save']")); }
public void IfCssAttributeContainsText(string obj, string attribute, string text) { String Text = _driver.FindElement(By.CssSelector(obj)).GetAttribute(attribute); Assert.IsTrue(Text.Contains(text), "Text: " + text + " not found or incorrect"); }
public List <IWebElement> GetProductsName() { var productNames = this.TransactionTableRoot.FindElements(By.CssSelector(".wpsc-purchase-log-transaction-results > tbody > tr > td:first-of-type")); return(productNames.ToList <IWebElement>()); }
public void IfClassContainsText(string obj, string text) { var Text = _driver.FindElement(By.CssSelector(obj)).Text; Assert.IsTrue(Text.Contains(text), "Text: " + text + " not found or incorrect"); }
public virtual void LocalCollectionActionsHonourMemberOrder() { GeminiUrl("object?i1=View&r1=1&o1=___1.SalesOrderHeader--71105&c1_Details=Table"); wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[0].FindElements(By.CssSelector("nof-action-bar nof-action")).Count >= 2); wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[0].FindElements(By.CssSelector("nof-action-bar nof-action input"))[0].GetAttribute("value") == "Add New Details"); wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[0].FindElements(By.CssSelector("nof-action-bar nof-action input"))[1].GetAttribute("value") == "Add New Detail"); wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[0].FindElements(By.CssSelector("nof-action-bar nof-action input"))[2].GetAttribute("value") == "Remove Details"); wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[0].FindElements(By.CssSelector("nof-action-bar nof-action input"))[3].GetAttribute("value") == "Adjust Quantities"); }
public void IfCssDoesNotContainText(string obj, string text) { var Text = _driver.FindElement(By.CssSelector(obj)).Text; Assert.IsFalse(Text.Contains(text)); }
public virtual void CannotInvokeZeroParamSelectionActionWithNothingSelected() { GeminiUrl("object?i1=View&r1=1&o1=___1.SalesOrderHeader--63023&c1_SalesOrderHeaderSalesReason=List"); Thread.Sleep(1000); wait.Until(dr => dr.FindElements(By.CssSelector(".collection"))[1].FindElements(By.CssSelector("nof-action input"))[1].GetAttribute("value") == "Remove Sales Reasons"); Thread.Sleep(1000); Click(GetLCA("Remove Sales Reasons")); WaitForTextEquals(".messages", 2, "Must select items for collection contributed action"); }
public void CssIsNotSelected(string obj) { IWebElement checkbox = _driver.FindElement(By.CssSelector(obj)); Assert.IsFalse(checkbox.Selected); }
public void LoginUser(String user) { new SelectElement(loginForm.FindElement(By.CssSelector("select"))).SelectByText(user); loginForm.Submit(); }
public static Dictionary <string, string> EditForm(this BasePage page) { var labelAndDones = new List <LabelAndDone>(); var dictionaryLabelsAndValues = new Dictionary <string, string>(); labelAndDones = page.CheckForNewLabels(labelAndDones); while (!IsEverythingDone(labelAndDones)) { labelAndDones = page.CheckForNewLabels(labelAndDones); var label = GetNextUndoneLabel(labelAndDones); var labelText = label.Text; var webElement = page.SwitchToTargetElementForLabel(labelText); if (webElement == null || !webElement.Enabled || !string.IsNullOrEmpty(webElement.GetAttribute("readonly"))) { MarkElementComplete(labelAndDones, dictionaryLabelsAndValues, labelText, ""); continue; } var tagName = webElement.TagName; var inputType = webElement.GetAttribute("type").ToLower(); if ((tagName == "select") || (tagName == "datalist")) { var selectElement = new SelectElement(webElement); string optionText; do { ChangeSelectElementValue(selectElement); var selectedOption = selectElement.SelectedOption; optionText = selectedOption.Text; } while (string.IsNullOrEmpty(optionText)); MarkElementComplete(labelAndDones, dictionaryLabelsAndValues, labelText, optionText); } else if (tagName == "input" && (inputType == "checkbox")) { webElement.Click(); var value = webElement.GetAttribute("checked"); if (value == "true") { value = "checked"; } MarkElementComplete(labelAndDones, dictionaryLabelsAndValues, labelText, value); } else if (tagName == "input" && (inputType == "radio")) { var valueToStore = ""; var currentRadioName = webElement.GetAttribute("name"); if (currentRadioName != lastRadioName) { lastRadioName = currentRadioName; firstRadio = webElement; nextRadioNeedsChecking = false; } if (nextRadioNeedsChecking) { webElement.Click(); valueToStore = "checked"; } var value = webElement.GetAttribute("checked"); if (nextRadioNeedsChecking) { nextRadioNeedsChecking = false; } else if (!string.IsNullOrEmpty(value)) { // if this one is checked then the next one needs to be checked nextRadioNeedsChecking = true; } //TODO: what if there is no next one, need to remember the first one MarkElementComplete(labelAndDones, dictionaryLabelsAndValues, labelText, valueToStore); } else // textarea plus input type=text, number, phone, date, email, etc. All assumed to be typeable { string newText = null; var originalText = webElement.GetAttribute("value"); if ((inputType == "number") || IsInputTextNumeric(originalText)) { newText = EditFormHelper.GetNewNumberText(webElement); } else if (inputType == "date") { var dateText = EditFormHelper.GetNewDateText(webElement); newText = dateText.Replace("/", ""); newText = newText.Replace("-", ""); webElement.SendKeys(newText); MarkElementComplete(labelAndDones, dictionaryLabelsAndValues, labelText, dateText); continue; } else { var placeholder = webElement.GetAttribute("placeholder"); if (!string.IsNullOrEmpty(placeholder) && placeholder.Contains("/")) { newText = EditFormHelper.GetNewDateText(webElement); } else { newText = originalText + "X"; } } if (inputType != "date") { webElement.Clear(); } webElement.SendKeys(newText); var list = webElement.GetAttribute("list"); if (!string.IsNullOrEmpty(list)) { webElement = page.GetElement(By.Id(list)); var anchors = webElement.FindElements(By.CssSelector("li a")); var anchor = anchors.First(); newText = anchor.Text; anchor.Click(); } MarkElementComplete(labelAndDones, dictionaryLabelsAndValues, labelText, newText); } } return(dictionaryLabelsAndValues); }
public void CanUpdateCheckboxStateWhileMovingIt() { var appElem = MountTestComponent <ReorderingFocusComponent>(); Func <IWebElement> checkboxFinder = () => appElem.FindElement(By.CssSelector(".item-2 input[type=checkbox]")); Func <IEnumerable <bool> > incompleteItemStates = () => appElem .FindElements(By.CssSelector(".incomplete-items input[type=checkbox]")) .Select(elem => elem.Selected); Func <IEnumerable <bool> > completeItemStates = () => appElem .FindElements(By.CssSelector(".complete-items input[type=checkbox]")) .Select(elem => elem.Selected); // Verify initial state Browser.Equal(new[] { false, false, false, false, false }, incompleteItemStates); Browser.Equal(Array.Empty <bool>(), completeItemStates); // Check a box; see it moves and becomes the sole checked item checkboxFinder().Click(); Browser.True(() => checkboxFinder().Selected); Browser.Equal(new[] { false, false, false, false }, incompleteItemStates); Browser.Equal(new[] { true }, completeItemStates); // Also uncheck it; see it moves and becomes unchecked checkboxFinder().Click(); Browser.False(() => checkboxFinder().Selected); Browser.Equal(new[] { false, false, false, false, false }, incompleteItemStates); Browser.Equal(Array.Empty <bool>(), completeItemStates); }
public bool IsOnThisPage() { return(IsElementPresent(By.CssSelector(".authentication__form-buttons input[value='Войти']"))); }