Advertisement
Atanasov_88

Untitled

Oct 7th, 2015
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. import org.junit.*;
  2. import org.openqa.selenium.By;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.WebElement;
  5. import org.openqa.selenium.firefox.FirefoxDriver;
  6. import sun.management.snmp.jvminstr.JvmThreadInstanceEntryImpl;
  7.  
  8. import java.util.concurrent.TimeUnit;
  9.  
  10. import static org.junit.Assert.*;
  11.  
  12. /**
  13.  * Created by kokoshkata on 10/6/2015.
  14.  */
  15. public class JustCodeQASoftUni {
  16.  
  17.     private WebDriver selenium;
  18.  
  19.     @Before
  20.  
  21.     public void setUp(){
  22.  
  23.         selenium = new FirefoxDriver();
  24.         selenium.manage().window().maximize();
  25.         selenium.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  26.  
  27.     }
  28.  
  29.     @Test
  30.  
  31.     public void testLogin(){
  32.  
  33.         selenium.get("http://softuni.bg");
  34.  
  35.         WebElement loginAvatar = selenium.findElement(By.className("user-avatar"));
  36.         loginAvatar.click();
  37.  
  38.         assertEquals("https://softuni.bg/login", selenium.getCurrentUrl());
  39.  
  40.         WebElement loginButton = selenium.findElement(By.id("LoginUserName"));
  41.         loginButton.clear();
  42.         loginButton.click();
  43.         loginButton.sendKeys("testtest".toLowerCase());
  44.  
  45.         WebElement loginPassword = selenium.findElement(By.id("LoginPassword"));
  46.         loginPassword.clear();
  47.         loginPassword.click();
  48.         loginPassword.sendKeys("testtest".toLowerCase());
  49.  
  50.         WebElement enterButton = selenium.findElement(By.xpath(("/html/body/div[2]/div[2]/div/div[1]/form/input[4]")));
  51.         enterButton.click();
  52.  
  53.         assertEquals("https://softuni.bg/users/profile/show", selenium.getCurrentUrl());
  54.  
  55.         WebElement dropDownName = selenium.findElement(By.xpath("/html/body/div[2]/div[2]/div[1]/div/div[1]/div/div/div[1]/div/div[2]/h2/strong"));
  56.  
  57.         assertEquals("testtest (testtest)", dropDownName.getText().trim());
  58.  
  59.  
  60.     }
  61.  
  62.     @After
  63.  
  64.     public void endTest(){
  65.  
  66.        // selenium.quit();
  67.     }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement