Package _01_webdriver

Source Code of _01_webdriver.WebdriverJavaJunitTest

package _01_webdriver;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import static org.junit.Assert.assertEquals;

@RunWith(JUnit4.class)
public class WebdriverJavaJunitTest {
    private static WebDriver driver;

    @BeforeClass
    public static void before() {
        driver = new ChromeDriver();
    }

    @AfterClass
    public static void after() {
        driver.quit();
    }

    @Test
    public void canLoginSuccessFully() {
        driver.get("http://localhost:5050/login");
        assertEquals(driver.findElement(By.tagName("h1")).getText(), "Please sign in");
        driver.findElement(By.name("username")).sendKeys("devoxx");
        driver.findElement(By.name("password")).sendKeys("devoxx");
        driver.findElement(By.tagName("button")).click();
        assertEquals(driver.findElement(By.tagName("h1")).getText(), "Login Successful");
    }
}
TOP

Related Classes of _01_webdriver.WebdriverJavaJunitTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.