public bool VerifyEmailAddress() { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); customWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("(//div[@class='row phone-data']//span[@class='form-value break-all'])[1]"))); bool emailAddressValue = false; for (int counter = 0; counter < newEmails.Count; counter++) { var emailCounter = counter + 1; string emailXpath = "(//div[@class='row phone-data']//span[@class='form-value break-all'])[" + emailCounter + "]"; string actualEmailText = driver.FindElement(By.XPath(emailXpath)).GetText(driver); string ExpectedEmail = newEmails[counter]; if (ExpectedEmail.Contains(actualEmailText)) { emailAddressValue = true; _logger.Info($" Email Is Correct"); } } return(emailAddressValue); }
/// <summary> /// Functions to click Save button and handle the smarty street if it populates /// </summary> /// <returns></returns> public EnterNewCustomerPage ClickEditSaveButton() { Thread.Sleep(2000); driver.WaitForElementToBecomeVisibleWithinTimeout(saveButtonEdit, 10000); saveButtonEdit.Clickme(driver); _logger.Info($": Successfully clicked on SAVE button for existing customer"); try { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); customWait.Until(ExpectedConditions.ElementIsVisible(By.Id("btnUseEnteredAddress"))); UseAddressAsEntered.Clickme(driver); _logger.Info($": Continue As Use address as entered on smarty street - If available"); } catch (Exception e) { try { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); customWait.Until(ExpectedConditions.ElementIsVisible(By.Id("btnCorrectAddress"))); AddressIsCorrect.Clickme(driver); _logger.Info($": Continue As This address is correct on smarty street - If available"); } catch (Exception e1) { Console.WriteLine(e1.StackTrace); } } return(this); }
public EnterNewCustomerPage ClickEditButton(string id) { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); customWait.Until(ExpectedConditions.ElementIsVisible(By.Id(id))); driver.FindElement(By.Id(id)).Clickme(driver); return(this); }
public static IWebElement waitElementIsVisibleById(String id) { ( new WebDriverWait(driver, TimeSpan.FromSeconds(30))).Until(ExpectedConditions.ElementIsVisible(By.Id(id))); IWebElement element = driver.FindElement(By.Id(id)); return(element); }
public void SelectElementWithWait(int index) { WebDriverWait wait = new WebDriverWait(DriverContext.WebDriver, TimeSpan.FromSeconds(30)); IWebElement element = wait.Until(ExpectedConditions.ElementIsVisible(ByLocator)); SelectElement select = new SelectElement(element); select.SelectByIndex(index); }
private bool IsLoginButtonDisplayed(IOSDriver <IOSElement> driver) { var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); var loginButton = wait.Until( ExpectedConditions.ElementIsVisible(MobileBy.AccessibilityId("test-LOGIN"))); return(loginButton.Displayed); }
public static IWebElement FindElement(this IWebDriver webDriver, By by, int timeoutInSeconds) { if (timeoutInSeconds > 0) { var wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(timeoutInSeconds)); wait.Until(ExpectedConditions.ElementIsVisible(by)); return(wait.Until(drv => drv.FindElement(by))); } return(webDriver.FindElement(by)); }
public void WaitUntilElementIsDisplayed() { try { Wait.Until(ExpectedConditions.ElementIsVisible(ByLocator)); } catch (Exception e) { logger.Error(e); } }
/// <summary> /// Functions to continue with existing customer /// </summary> /// <returns></returns> /// public EnterNewCustomerPage UpdateExistingCustomerFromCustomerSuggestion() { try { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); customWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='btnSection']/div/div[1]/div[2]/div/div/div/div/div/div[2]/div/div[1]"))); continueWithExistingCustomer.Clickme(driver); _logger.Info($": Selects existing customer"); } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(this); }
/// <summary> /// Functions to continue with new customer /// </summary> /// <returns></returns> public EnterNewCustomerPage ContinueNewCustomerCreation() { try { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); customWait.Until(ExpectedConditions.ElementIsVisible(By.Id("btnContinue"))); continueWithNewCustomer.Clickme(driver); _logger.Info($": Continue As New Customer button - If available"); } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(this); }
/// <summary> /// Verify Green Banner /// </summary> /// <returns></returns> public bool VerifyGreedbarAfterEditIsSuccessful() { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); customWait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("msg-container"))); bool editButtonAvailibility = false; if (GreenBar.Displayed) { editButtonAvailibility = true; _logger.Info($" Edit Button is Available"); } return(editButtonAvailibility); }
/// <summary> /// Verify last name is same as entered /// </summary> /// <param name="LastNameOnScreen"></param> /// <returns></returns> public bool VerifyLastName(String lastNameOnFile) { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); customWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='col-sm-6 pad-left-none']//span[@class='form-value']"))); String LastName = LastNameText.GetText(driver); bool lastNameValue = false; Thread.Sleep(1000); if (LastName.Contains(lastNameOnFile)) { lastNameValue = true; _logger.Info($" Last Name Is Correct"); } return(lastNameValue); }
public bool VerifyTaxidNumberAndState() { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); customWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("(//div[@class='row phone-data']//span[@class='form-value'])[5]"))); bool taxIdNumberAndStateValue = false; for (int counter = 0; counter < newTax.Count; counter++) { var taxNumberCounter = counter + 5; string taxNumberXpath = "(//div[@class='row phone-data']//span[@class='form-value'])[" + taxNumberCounter + "]"; string taxNumber = driver.FindElement(By.XPath(taxNumberXpath)).GetText(driver); string expectedTaxIdNumber = newTax[counter].Item1; if (expectedTaxIdNumber.Contains(taxNumber)) { taxIdNumberAndStateValue = true; _logger.Info($" TaxidNumber Is Correct"); } var taxStateCounter = taxNumberCounter + 1; string taxStateXpath = "(//div[@class='row phone-data']//span[@class='form-value'])[" + taxStateCounter + "]"; string actaulTaxState = driver.FindElement(By.XPath(taxStateXpath)).GetText(driver); string expectedTaxState = newTax[counter].Item2; if (expectedTaxState.Contains(actaulTaxState)) { taxIdNumberAndStateValue = true; _logger.Info($"Tax state Is Correct"); } } return(taxIdNumberAndStateValue); }
public void RegistrationCheckTest() { try { driver.Navigate().GoToUrl(url); IWebElement izlistaj = wait.Until(EC.ElementIsVisible(By.LinkText("Izlistaj sve korisnike"))); if (izlistaj.Displayed && izlistaj.Enabled) { izlistaj.Click(); } IWebElement table = wait.Until(EC.ElementIsVisible(By.XPath("//table//td"))); if (table.Displayed && table.Enabled) { bool registered = false; ReadOnlyCollection <IWebElement> listOfEmails = table.FindElements(By.XPath("//table//td[contains(text(),'@')]")); foreach (IWebElement email in listOfEmails) { if (email.Text == "*****@*****.**") { registered = true; } } if (registered) { Assert.Pass(); } else { Assert.Fail(); } } } catch (NoSuchElementException) { } }
/// <summary> /// Veerify Phone Number is same as entered /// </summary> /// <param name="EnteredPhone"></param> /// <returns></returns> public bool VerifyPhoneNumberAndPhoneType() { WebDriverWait customWait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); customWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("(//div[@class='row phone-data']//span[@class='form-value'])[1]"))); bool PhoneNumberAndTypeValue = false; for (int counter = 0; counter < newPhones.Count; counter++) { var phoneCounter = counter * 2 + 1; string phoneNumberXpath = "(//div[@class='row phone-data']//span[@class='form-value'])[" + phoneCounter + "]"; string phoneNumber = driver.FindElement(By.XPath(phoneNumberXpath)).GetText(driver); string actualPhoneNumber = string.Concat(phoneNumber.Substring(1, 3), phoneNumber.Substring(6, 3), phoneNumber.Substring(10, 4)); string ExpectedPhone = newPhones[counter].Item1; if (ExpectedPhone.Contains(actualPhoneNumber)) { PhoneNumberAndTypeValue = true; _logger.Info($" Phone Is Correct"); } var phonetypecounter = phoneCounter + 1; string Phonetypexpath = "(//div[@class='row phone-data']//span[@class='form-value'])[" + phonetypecounter + "]"; string ActualPhoneType = driver.FindElement(By.XPath(Phonetypexpath)).GetText(driver); string ExpectedPhoneType = newPhones[counter].Item2; if (ExpectedPhoneType.Contains(ActualPhoneType)) { PhoneNumberAndTypeValue = true; _logger.Info($" Phone Is Correct"); } } return(PhoneNumberAndTypeValue); }
private static IWebElement FindBy(IWebDriver driver, By by, int timeout) { driver.Wait(ExpectedConditions.ElementIsVisible(by), timeout); return(driver.FindElement(by)); }
public void WaitSecsForText(int seconds, string screentext, string drivertype = "chrome") { new WebDriverWait(_webDriver.WebDriver(drivertype), TimeSpan.FromSeconds(seconds)) .Until(ExpectedConditions.ElementIsVisible(By.LinkText(screentext))); }
public void WaitSecsForObjectByClass(int seconds, string classname, string drivertype = "chrome") { new WebDriverWait(_webDriver.WebDriver(drivertype), TimeSpan.FromSeconds(seconds)) .Until(ExpectedConditions.ElementIsVisible(By.ClassName(classname))); }
public void WaitsecondsId(int seconds, string elementId, string drivertype = "chrome") { new WebDriverWait(_webDriver.WebDriver(drivertype), TimeSpan.FromSeconds(seconds)) .Until(ExpectedConditions.ElementIsVisible(By.Id(elementId))); }
public void TestRegistration() { try { IWebElement newUser = wait.Until(EC.ElementIsVisible(By.LinkText("Kreiraj novog korisnika"))); if (newUser.Displayed && newUser.Enabled) { newUser.Click(); } } catch (WebDriverTimeoutException) { Assert.Fail("Element showing took too long."); } try { IWebElement RegisterBtn = driver.FindElement(By.Name("register")); if (RegisterBtn.Displayed && RegisterBtn.Enabled) { IWebElement form_name = driver.FindElement(By.Name("ime")); if (form_name.Displayed && form_name.Enabled) { form_name.Clear(); form_name.SendKeys("Tamara"); } IWebElement form_lastname = driver.FindElement(By.Name("prezime")); if (form_lastname.Displayed && form_lastname.Enabled) { form_lastname.Clear(); form_lastname.SendKeys("Smiljanić"); } IWebElement form_Username = driver.FindElement(By.Name("korisnicko")); if (form_Username.Displayed && form_Username.Enabled) { form_Username.Clear(); form_Username.SendKeys("Smiljka1979"); } IWebElement form_email = driver.FindElement(By.Name("email")); if (form_email.Displayed && form_email.Enabled) { form_email.Clear(); form_email.SendKeys(Test_Data_email); } IWebElement form_phone = driver.FindElement(By.Name("telefon")); if (form_phone.Displayed && form_phone.Enabled) { form_phone.Clear(); form_phone.SendKeys("+381695555555"); } IWebElement form_state = driver.FindElement(By.Id("zemlja")); if (form_state.Enabled) { SelectElement state = new SelectElement(form_state); state.SelectByValue("ita"); } try { IWebElement form_city = wait.Until(EC.ElementToBeClickable(By.XPath("//select[@name='grad']"))); { if (form_city.Enabled) { SelectElement city = new SelectElement(form_city); city.SelectByValue("Ancona"); System.Threading.Thread.Sleep(4000); } } } catch (WebDriverTimeoutException) { Assert.Fail("Test failed = it took too long for element to show"); } IWebElement form_address = driver.FindElement(By.XPath("//div[contains(text(),'Ulica i broj')]//following::input")); if (form_address.Displayed && form_address.Enabled) { form_address.Clear(); form_address.SendKeys("Ive Andrica 11"); } IWebElement form_sex = driver.FindElement(By.Id("pol_z")); if (form_sex.Displayed && form_sex.Enabled) { form_sex.Click(); } IWebElement form_newsletter = driver.FindElement(By.Id("newsletter")); if (form_newsletter.Displayed && form_newsletter.Enabled) { form_newsletter.Click(); } RegisterBtn.Click(); Assert.Pass(); } } catch (WebDriverTimeoutException) { Assert.Fail(); } }
//<Summary> // This method waits until UI web element is found. //This method takes wait time and element to be found as parameter //</summary> public static void WaitForElement(int seconds, By by) { WebDriverWait driverWait = new WebDriverWait(Driver.driver, TimeSpan.FromSeconds(seconds)); driverWait.Until(ExpectedConditions.ElementIsVisible(by)); }
/// <summary> /// Waits for the provided element to be visible. /// <para /> /// The default wait timeout is 30 seconds but can be overridden for another value. /// </summary> /// <param name="element"></param> /// <param name="maxTimeoutInSeconds"></param> public void WaitForElementToBeVisible(By element, int maxTimeoutInSeconds = 30) { try { new WebDriverWait(driver, TimeSpan.FromSeconds(maxTimeoutInSeconds)).Until(ExpectedConditions.ElementIsVisible(element)); } catch (Exception e) { MyLogger.Log.Error($"Failed to wait for element: {element} to be visible. {e.Message}"); throw e; } }
public void TestOrder() { IWebElement searchQuery = wait.Until(EC.ElementIsVisible(By.Id("search_query_top"))); if (searchQuery.Enabled) { searchQuery.SendKeys("faded"); IWebElement searchButton = wait.Until(EC.ElementToBeClickable(By.Name("submit_search"))); searchButton.Click(); } IWebElement product = wait.Until(EC.ElementIsVisible(By.LinkText("Faded Short Sleeve T-shirts"))); if (product.Displayed) { product.Click(); } IWebElement productQuantity = wait.Until(EC.ElementIsVisible(By.Id("quantity_wanted"))); if (productQuantity.Enabled) { productQuantity.Clear(); productQuantity.SendKeys("2"); } IWebElement productSize = driver.FindElement(By.Id("group_1")); if (productSize.Enabled) { SelectElement size = new SelectElement(productSize); size.SelectByText("L"); } IWebElement AddToChartButton = wait.Until(EC.ElementToBeClickable(By.Name("Submit"))); if (AddToChartButton.Enabled) { AddToChartButton.Click(); } IWebElement verification = wait.Until(EC.ElementIsVisible(By.ClassName("icon-ok"))); if (verification.Displayed) { IWebElement continueShopingBtn = wait.Until(EC.ElementIsVisible(By.ClassName("icon-chevron-left"))); if (continueShopingBtn.Displayed) { continueShopingBtn.Click(); Assert.Pass("Test is passed - all elements function"); } } else { Assert.Fail("Test failed - Shoping chart isn't verified"); } System.Threading.Thread.Sleep(6000); }