Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devops-school/b7b718ee6a12806d0ec877d9df57c0a0 to your computer and use it in GitHub Desktop.
Save devops-school/b7b718ee6a12806d0ec877d9df57c0a0 to your computer and use it in GitHub Desktop.
package seleniumtest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.events.WebDriverEventListener;
/**
* @Rajesh Kumar via DevOpsSchool.com
*/
public class SeleniumFirefoxDriverwordpress {
static WebDriver webDriver;
/**
* @param args
* @throws InterruptedException
*/
public static void main(final String[] args) throws InterruptedException {
// Telling the system where to find the chrome driver
System.setProperty("webdriver.chrome.driver","C:\\Tools\\selenium\\chromedriver.exe");
System.setProperty("webdriver.gecko.driver","C:\\Tools\\selenium\\geckodriver.exe");
// Open the Chrome browser
// webDriver = new ChromeDriver();
WebDriver driver = new FirefoxDriver();
String baseUrl = "https://www.devopsschool.com/notes/selenium/index.html";
String expectedTitle = "Welcome to DevOpsSchool.com";
String actualTitle = "";
// launch Fire fox and direct it to the Base URL
driver.get(baseUrl);
// get the actual value of the title
actualTitle = driver.getTitle();
/*
* compare the actual title of the page with the expected one and print
* the result as "Passed" or "Failed"
*/
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
//close Fire fox
driver.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment