Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static org.junit.Assert.assertEquals;
- import org.junit.AfterClass;
- import org.junit.Before;
- import org.junit.Test;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.safari.SafariDriver;
- import org.openqa.selenium.support.ui.Select;
- public class ZeroWebAppSecurity {
- public static WebDriver driver;
- @Before
- public void setUp() throws Exception {
- //System.setProperty("webdriver.firefox.bin","C:\\Program Files\\Mozilla Firefox Old\\firefox.exe");
- //System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
- driver = new SafariDriver();
- }
- @Test
- public void test() throws InterruptedException {
- driver.get("http://zero.webappsecurity.com/");
- WebElement signinBtn = driver.findElement(By.id("signin_button"));
- signinBtn.click();
- // login
- WebElement username = driver.findElement(By.id("user_login"));
- username.sendKeys("username");
- WebElement password = driver.findElement(By.id("user_password"));
- password.sendKeys("password");
- password.submit();
- // click pay bills
- WebElement payBillsLink = driver.findElement(By.linkText("Pay Bills"));
- payBillsLink.click();
- // click Purchase Foreign Currency
- WebElement purchaseLink = driver.findElement(By.linkText("Purchase Foreign Currency"));
- purchaseLink.click();
- // wait for the page to load, then select Canadian dollar
- Thread.sleep(500);
- Select currencySelect = new Select(driver.findElement(By.id("pc_currency")));
- currencySelect.selectByValue("CAD");
- // enter amount
- WebElement amount = driver.findElement(By.id("pc_amount"));
- amount.sendKeys("100");
- // select us dollars
- WebElement usDollars = driver.findElement(By.id("pc_inDollars_true"));
- usDollars.click();
- // click the calculate costs button
- WebElement calcCostsBtn = driver.findElement(By.id("pc_calculate_costs"));
- calcCostsBtn.click();
- // wait for the calculation
- Thread.sleep(250);
- // assert test
- WebElement resultLabel = driver.findElement(By.id("pc_conversion_amount"));
- assertEquals(resultLabel.getText(), "94.19 dollar (CAD) = 100.00 U.S. dollar (USD)");
- }
- @AfterClass
- public static void afterClass() {
- // closes the browser
- driver.quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement