Selenium Sample Program
Selenium Sample Program
PROGRAM
-------------------------------
package newproject;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//comment the above line and uncomment below line to use Chrome
//import org.openqa.selenium.chrome.ChromeDriver;
public class PG1 {
/*
* 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");
}
}
12 Aug.
}
--------------******--------------*******---------------*********-----
EXPLAINATION
********----*****----*****---
Importing Packages
To get started, you need to import following two packages:
A FirefoxDriver class with no parameters means that the default Firefox profile
will be launched by our Java program. The default Firefox profile is similar to
launching Firefox in safe mode (no extensions are loaded).
For convenience, we saved the Base URL and the expected title as variables.