// User is able to convert 1 Swiss Franc to EURO successfully public void Story2ConvertSwissFrancToEuro() { TestContext.WriteLine("Convert Swiss Franc to EURO"); NavigateToCurrencyConverter(); if (IsElementFound(By.Id("westpac-iframe"), out IWebElement westpacFrame)) { //switch to the westpac-iframe driver.SwitchTo().Frame(westpacFrame); } if (IsElementFound(By.Id("ConvertFrom"), out IWebElement ConvertFromDropDown)) { ConvertFromDropDown.FindElement(By.XPath("//select[1]/option[9]")).Click(); } if (IsElementFound(By.Id("ConvertTo"), out IWebElement ConvertToDropDown)) { ConvertToDropDown.FindElement(By.XPath("//select[2]/option[5]")).Click(); } if (IsElementFound(By.Id("Amount"), out IWebElement AmountInput)) { AmountInput.SendKeys("1"); } if (IsElementFound(By.Id("convert"), out IWebElement ConvertButton)) { ConvertButton.Click(); String ActualText = ""; if (IsElementFound(By.Id("resultsdiv"), out IWebElement ResultText)) { ActualText = ResultText.Text; } String FailedMessage = "failed to convert Swiss Franc to Euro"; Assert.IsTrue(ActualText.Contains("1 Swiss Franc"), FailedMessage); Assert.IsTrue(ActualText.Contains("Euro"), FailedMessage); Assert.IsTrue(ActualText.Contains("Would you like to make another calculation"), FailedMessage); } }
public void Story1NoAmountEntered() { TestContext.WriteLine("No amount entered, convert button is clicked"); NavigateToCurrencyConverter(); if (IsElementFound(By.Id("westpac-iframe"), out IWebElement westpacFrame)) { //switch to the westpac-iframe driver.SwitchTo().Frame(westpacFrame); } if (IsElementFound(By.Id("convert"), out IWebElement ConvertButton)) { ConvertButton.Click(); String ExpectedText = "Please enter the amount you want to convert."; String ActualText = ""; if (IsElementFound(By.Id("errordiv"), out IWebElement ErrorText)) { ActualText = ErrorText.Text; } TestContext.WriteLine("ActualText is " + ActualText); Assert.AreEqual(ExpectedText, ActualText, "failed to find " + ExpectedText); } }