package dayOne;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestTwo {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://enterprise.demo.orangehrmlive.com/";
StringBuffer expectedTitle = new StringBuffer("OrangeHRM");
String actualTitle = "";
driver.get(baseUrl);
actualTitle = driver.getTitle();
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
driver.close();
}
}
Code Explanation :
- org.openqa.selenium.*- The WebDriver class needed to instantiate a new browser loaded with a specific driver .
- org.openqa.selenium.firefox.FirefoxDriver - The FirefoxDriver class needed to instantiate a Firefox-specific driver onto the browser instantiated by the WebDriver class
- WebDriver driver = new FirefoxDriver(); - Instantiating objects and variables
driver.get(baseUrl); - Launching a Browser Session.
actualTitle = driver.getTitle(); - Get the Actual Page Title.
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");} else {System.out.println("Test Failed");}
Compare the Expected and Actual Values.
driver.close(); - Terminating a Browser Session.
This article really helps me to know more about this technology.Thanks for sharing this information in your blog, keep doing this continuously.
ReplyDeleteSelenium Training in Chennai
Selenium Course in Chennai
Selenium Training in Velachery
Selenium Training in Tambaram
Selenium Training in Anna Nagar
Software Testing Training in Chennai
Software Testing Course in Chennai
Software Testing Training in Velachery