public void Test01() { ExReports.createTest("Login with invalid UserName and Pass"); lp.clearUserNameAndPass(); lp.inputCredentialsAndSubmit(INVALID_LOGON, INVALID_PASS); lp.checkErrorMessage(AUTORIZATION_ERROR_MESSAGE); lp.checkUserNameAndPassAreEmpty(); }
public void Test03() { ExReports.createTest("Login with Password only"); lp.clearUserNameAndPass(); lp.fillPass(PASS); lp.clickSubmitButton(); lp.checkErrorMessage("ERROR: The username field is empty."); lp.checkUserNameAndPassAreEmpty(); }
public void Test04() { ExReports.createTest("Login with valid credentials"); lp.clearUserNameAndPass(); lp.inputCredentialsAndSubmit(USER_NAME, PASS); Profile.goToStore(); Common.checkElementIsDisplayed("Logo", "logo"); ExReports.reportPass("Login is successful"); }
public void Test02() { ExReports.createTest("Login with UserName only"); lp.clearUserNameAndPass(); lp.fillUserName(USER_NAME); lp.clickSubmitButton(); lp.checkErrorMessage("ERROR: The password field is empty."); Common.checkFieldValue("user_login", USER_NAME); Common.checkFieldIsEmpty("Password", "user_pass"); }
public void isElementPresent() { try { Assert.IsTrue(Common.waitForElementIsPresent("First name field", "name", "firstname", Constants.TIME_OUT)); } catch (AssertFailedException e) { ExReports.reportFail("Element is on the page" + e.Message); throw; } }
public void fillUserName(string sUserName) { try { Common.fillField("User name", "id", "user_login", sUserName); } catch (Exception e) { ExReports.reportFail(e.Message); throw; } }
public void clickLink(string sLink) { try { getDriver.FindElement(By.LinkText(sLink)).Click(); ExReports.reportPass("Link is selected"); } catch (Exception e) { ExReports.reportFail("Link is not clicked. " + e.Message); throw; } }
public void checkFieldIsEmpty(string sName, string sObjectLocator) { try { waitForElementIsPresent(sName, Constants.TIME_OUT, sObjectLocator); Assert.IsTrue(String.IsNullOrEmpty(getDriver.FindElement(By.Id(sObjectLocator)).GetAttribute("value"))); ExReports.reportPass("Field '" + sName + "' is empty"); } catch (AssertFailedException) { ExReports.reportFail("Field '" + sName + "' is not empty"); throw; } }
/// <Wait methods> public void waitForElementIsPresent(string sName, int iTimeOut, string sObjectLocator) { try { WebDriverWait wait = new WebDriverWait(getDriver, TimeSpan.FromSeconds(iTimeOut)); wait.Until(ExpectedConditions.ElementIsVisible((By.Id(sObjectLocator)))); ExReports.reportInfo("Element '" + sName + "' is found"); } catch (WebDriverTimeoutException) { ExReports.reportFail("Timeout is over - Element '" + sName + "' is not found"); throw; } }
public void pressBack() { try { driver.Navigate().Back(); ExReports.reportPass("'Back' button is clicked"); } catch (Exception e) { ExReports.reportFail(e.Message); throw; } }
public void selectProfessionYearsAndTool() { try { Profession.Click(); Experience.Click(); Tool.Click(); } catch (Exception e) { ExReports.reportFail(e.Message); throw; } }
public void addToCard() { try { Common.waitForElementIsPresent("Add to Card button", "classname", "wpsc_buy_button", Constants.TIME_OUT); BtnAddToCard.Click(); ExReports.reportPass("Button 'Add to card' is clicked"); } catch (Exception e) { ExReports.reportFail("Add to card" + e.Message); throw; } }
public void checkFieldValue(string sObjectLocator, string sValue) { try { waitForElementIsPresent(sValue, Constants.TIME_OUT, sObjectLocator); Assert.AreEqual(getDriver.FindElement(By.Id(sObjectLocator)).GetAttribute("value"), sValue); ExReports.reportPass("Check field - Value '" + sValue + "' is correct"); } catch (AssertFailedException) { ExReports.reportFail("Check field - Value '" + sValue + "' is not correct"); throw; } }
public void openItem() { try { Common.waitForElementIsPresent("Item link", "xpath", "//*[text()='iPhone 5']", Constants.TIME_OUT); lnkItem.Click(); ExReports.reportPass("'Item link' is selected"); } catch (Exception e) { ExReports.reportFail("Open item" + e.Message); throw; } }
public void checkElementIsDisplayed(string sName, string sObjectLocator) { try { waitForElementIsPresent(sName, Constants.TIME_OUT, sObjectLocator); Assert.IsTrue(getDriver.FindElement(By.Id(sObjectLocator)).Displayed); ExReports.reportPass("Element '" + sName + "' is displayed"); } catch (AssertFailedException e) { ExReports.reportFail("Element '" + sName + "' is not displayed. " + e.Message); throw; } }
public void inputCredentialsAndSubmit(string sUserName, string sPassword) { try { fillUserName(sUserName); fillPass(sPassword); clickSubmitButton(); } catch (Exception e) { ExReports.reportFail(e.Message); throw; } }
public void checkTextIsPresent(string sText) { try { WebDriverWait wait = new WebDriverWait(getDriver, TimeSpan.FromSeconds(Constants.TIME_OUT)); wait.Until(ExpectedConditions.ElementIsVisible((By.XPath(String.Format("//*[contains(text(), '" + sText + "')]"))))); ExReports.reportPass("Text '" + sText + "' is found on page"); } catch (WebDriverTimeoutException) { ExReports.reportFail("Text '" + sText + "' is not found on page"); throw; } }
public void selectCommands() { try { SelectElement oSelect = new SelectElement(Commands); oSelect.SelectByText("Navigation Commands"); oSelect.SelectByText("Wait Commands"); ExReports.reportPass("Two commands are selected"); } catch (Exception e) { ExReports.reportFail(e.Message); throw; } }
public void fillUserFields() { try { FirstName.SendKeys("Gleb"); ExReports.reportPass("'First name' field is filled"); LastName.SendKeys("Shustin"); ExReports.reportPass("'Last name' field is filled"); } catch (Exception e) { ExReports.reportFail(e.Message); throw; } }
public void submitItem() { try { Common.waitForElementIsPresent("First name field", "xpath", "//input[@id='wpsc_checkout_form_2']", Constants.TIME_OUT); BtnSubmit.Click(); ExReports.reportPass("'Purchase' button is clicked"); Common.checkTextIsPresent("Thank you, your purchase is pending"); } catch (Exception e) { ExReports.reportFail("Submit Item error" + e.Message); throw; } }
public void createFile(string sFileName) { try { if (File.Exists(sFileName)) { File.Delete(sFileName); } File.Create(sFileName); } catch (Exception e) { ExReports.reportFail("File is not created. " + e.Message); } }
public void Test05() { ExReports.createTest("Automation Practice Form"); FormPage f = new FormPage(BaseClass.getDriver); BaseClass.goToURL(FORM_URL); f.isElementPresent(); f.selectLinks(); f.fillUserFields(); f.fillDate(); f.selectSex(); f.selectProfessionYearsAndTool(); f.selectContinent(); f.selectCommands(); }
public void searchItem(string sItemName) { try { Common.waitForElementIsPresent("Search", "name", "s", Constants.TIME_OUT); SearchField.SendKeys(sItemName); ExReports.reportPass("'Search' field is filled"); SearchField.SendKeys(Keys.Enter); ExReports.reportPass("'Enter' is pressed"); } catch (Exception e) { ExReports.reportFail("Search item" + e.Message); throw; } }
public void chooseProfilePicture() { try { Common.createFile(sUploadPath); BtnChooseFile.Click(); SendKeys.SendWait(sUploadPath); SendKeys.SendWait(@"{Enter}"); ExReports.reportPass("File '" + UPLOAD_FILE_NAME + "' is uploaded"); } catch (Exception e) { ExReports.reportFail("File '" + UPLOAD_FILE_NAME + "' is not uploaded. " + e.Message); throw; } }
public void checkMessage(string sType, string sObjectLocator, string sMessage) { try { switch (sType) { case "id": waitForElementIsPresent(sMessage, Constants.TIME_OUT, sObjectLocator); Assert.AreEqual(getDriver.FindElement(By.Id(sObjectLocator)).Text, sMessage); ExReports.reportInfo("Message '" + sMessage + "' is checked"); break; } } catch (AssertFailedException e) { ExReports.reportFail("Message '" + sMessage + "' is not checked. " + e.Message); throw; } }
public static void Init(string sURL) { switch (sBrowser) { case "Firefox": driver = new FirefoxDriver(); break; case "Chrome": ChromeOptions option = new ChromeOptions(); option.AddArguments("disable-infobars"); driver = new ChromeDriver(option); break; } ExReports.addReport(); driver.Manage().Window.Maximize(); goToURL(sURL); }
public void selectLinks() { try { PartialLink.Click(); ExReports.reportPass("Partial Link is clicked"); Link.Click(); ExReports.reportPass("Link is clicked"); Common.checkTextIsPresent("Burj Khalifa"); ExReports.reportPass("Table page is loaded"); pressBack(); Common.checkTextIsPresent("Practice Automation Form"); ExReports.reportPass("Form page is loaded"); } catch (Exception e) { ExReports.reportFail(e.Message); throw; } }
public void Test01() { ExReports.createTest("Find and purchase item"); StorePage s = new StorePage(BaseClass.getDriver); s.searchItem("iphone"); s.openItem(); s.addToCard(); s.checkOutItem(); s.mail = "*****@*****.**"; s.firstName = "Gleb"; s.lastName = "Shustin"; s.address = "9041 E Shorewood Dr."; s.city = "Seattle"; s.state = "WA"; s.county = "USA"; s.phone = "4255335454"; s.submitItem(); }
public void clearField(string sFieldName, string sType, string sObjectLocator) { try { waitForElementIsPresent(sFieldName, Constants.TIME_OUT, sObjectLocator); switch (sType) { case "id": getDriver.FindElement(By.Id(sObjectLocator)).Clear(); break; case "name": getDriver.FindElement(By.Name(sObjectLocator)).Clear(); break; } ExReports.reportPass("Clear field - Field '" + sFieldName + "' is cleared"); } catch (Exception e) { ExReports.reportFail("Field '" + sFieldName + "' is not cleared. " + e.Message); throw; } }
public void selectRadioBtn(string sName) { try { IList <IWebElement> oRadioButton = getDriver.FindElements(By.Name(sName)); bool bValue = false; bValue = oRadioButton.ElementAt(0).Selected; if (bValue == true) { oRadioButton.ElementAt(1).Click(); } else { oRadioButton.ElementAt(0).Click(); } } catch (Exception e) { ExReports.reportFail("Radiobutton is not selected. " + e.Message); throw; } }