Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.util.concurrent.TimeUnit;
- import org.junit.After;
- import org.junit.AfterClass;
- import org.junit.Before;
- import org.junit.BeforeClass;
- import org.junit.Test;
- import static org.junit.Assert.*;
- import static org.openqa.grid.common.SeleniumProtocol.WebDriver;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import static javaapplication4.Util.*;
- import org.openqa.selenium.Alert;
- import org.openqa.selenium.support.ui.ExpectedConditions;
- import org.openqa.selenium.support.ui.Select;
- import org.openqa.selenium.support.ui.WebDriverWait;
- /**
- *
- * @author ResulKerimov
- */
- public class AuthJUnitTest {
- public AuthJUnitTest() {
- }
- @BeforeClass
- public static void setUpClass() {
- }
- @AfterClass
- public static void tearDownClass() {
- }
- @Before
- public void setUp() {
- System.setProperty("webdriver.chrome.driver",
- "C:\\Users\\ResulKerimov\\Desktop\\chromedriver.exe");
- DRIVER.get(BASE_URL);
- DRIVER.manage().timeouts().implicitlyWait(WAIT_TIME, TimeUnit.SECONDS);
- //WebDriverWait wait = new WebDriverWait(DRIVER, 5000);
- //WebElement user = DRIVER.findElement(By.id("username"));
- //WebElement pass = DRIVER.findElement(By.id("password"));
- //DRIVER.findElement(By.cssSelector("button[type='submit']")).click();
- }
- @After
- public void tearDown() {
- }
- @Test
- public void test() throws Exception {
- String URL = DRIVER.getCurrentUrl();
- String[][] testData = getDataFromExcel(FILE_PATH,
- SHEET_NAME, TABLE_NAME);
- System.out.println(testData.length);
- for (int i = testData.length - 1; i >= 0; i--) {
- String username = testData[i][0]; // get username
- String password = testData[i][1]; // get password
- DRIVER.findElement(By.cssSelector("input[placeholder='Network username']")).clear();
- DRIVER.findElement(By.cssSelector("input[placeholder='Network username']")).sendKeys(username);
- // Enter Password
- DRIVER.findElement(By.cssSelector("input[placeholder='Password']")).clear();
- DRIVER.findElement(By.cssSelector("input[placeholder='Password']")).sendKeys(password);
- // FOR .ORG DOMAINS
- Select sc = new Select(DRIVER.findElement(By.tagName("select")));
- sc.selectByIndex(1);
- DRIVER.findElement(By.cssSelector("button[type='submit']")).click();
- System.out.println(i);
- if(i > 0) {
- assertEquals(ERROR_AUTH_WRONG_DATA, DRIVER.getCurrentUrl(), URL);
- } else {
- assertNotEquals(ERROR_AUTH_CORRECT_DATA, DRIVER.findElements(By.cssSelector("div[class='media-body']")).size(), 0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement