Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.junit.After;
- 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.firefox.FirefoxDriver;
- import static org.junit.Assert.assertEquals;
- public class testautomationclass {
- private WebDriver selenium;
- @Before
- public void setUp () {
- selenium = new FirefoxDriver();
- }
- @Test
- public void TestLoginExpectedScenario () {
- String validUsername = "testtest";
- String validPassword = "testtest";
- selenium.get("http://softuni.bg");
- WebElement loginLink = selenium.findElement(By.id("loginLink"));
- loginLink.click();
- assertEquals("https://softuni.bg/account/authenticate", selenium.getCurrentUrl());
- WebElement usernameField = selenium.findElement(By.id("LoginUserName"));
- WebElement passwordField = selenium.findElement(By.id("LoginPassword"));
- usernameField.clear();
- usernameField.sendKeys(validUsername);
- passwordField.clear();
- passwordField.sendKeys(validPassword);
- WebElement loginButton = selenium.findElement(By.xpath("//input[@value='ΠΡ ΠΎΠ΄']"));
- loginButton.click();
- assertEquals("https://softuni.bg/users/profile/show", selenium.getCurrentUrl());
- WebElement dropDownUserName = selenium.findElement(By.xpath("/html/body/header/div/div/div/div/nav/div/div[2]/form/ul/li[2]/a"));
- assertEquals(validUsername.toUpperCase(), dropDownUserName.getText().trim());
- }
- @After
- public void tearDown () {
- selenium.close();
- try
- {
- Thread.sleep(5000);
- selenium.quit();
- }
- catch(Exception e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement