Advertisement
mourya2175

basic_Auth

Oct 20th, 2015
13,133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. package sample;
  2.  
  3. import java.util.concurrent.TimeUnit;
  4.  
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.WebDriver;
  7. import org.openqa.selenium.chrome.ChromeDriver;
  8. import org.testng.Assert;
  9. import org.testng.annotations.AfterClass;
  10. import org.testng.annotations.BeforeClass;
  11. import org.testng.annotations.Test;
  12.  
  13. public class Basic_Auth {
  14.     public WebDriver driver;
  15.     @Test
  16.     public void testBasicAuth() {
  17.         //UserName --admin
  18.         //Password --admin
  19.         //URL --- http://the-internet.herokuapp.com/basic_auth
  20.         //Updated URl -- http://admin:admin@the-internet.herokuapp.com/basic_auth
  21.         driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth");
  22.         //assert Text
  23.         String actualText=driver.findElement(By.xpath("//div[@class='example']/p")).getText();
  24.         Assert.assertEquals(actualText, "Congratulations! You must have the proper credentials.");
  25.         System.out.println("Test passed");
  26.     }
  27.     @BeforeClass
  28.     public void beforeClass() {
  29.         System.setProperty("webdriver.chrome.driver", "D:\\Jar\\chromedriver.exe");
  30.         driver = new ChromeDriver();
  31.         driver.manage().window().maximize();
  32.         driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  33.     }
  34.  
  35.     @AfterClass
  36.     public void afterClass() {
  37.         driver.quit();
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement