Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this tutorial, we will create a JUnit4 Test Case in Java using Selenium for browser automation.


Info
titlePlease note

There is a more up-to-date tutorial using JUnit5 providing additional capabilities. Please check it instead.

Description


Code Block
languagejava
package selenium_sample;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class JTest1 {
    @Test
    public void startWebDriver(){

        //WebDriver driver = new FirefoxDriver();
        WebDriver driver = new ChromeDriver();
        driver.navigate().to("http://seleniumsimplified.com");
        Assert.assertTrue("title should start differently",
                            driver.getTitle().startsWith("Selenium Simplified"));
        driver.close();
        driver.quit();
    }
}

...