Working with Firefox Browser
package com.practiceCode;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
/**
* @Blog Name : Selenium Code Example
* @author Deepak Gupta
* @Created Date 9-08-2017
*
*/
public class FirefoxBrowser {
WebDriver driver;
@BeforeTest
public void testFirefoxBrowser() {
try {
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "/drivers/geckodriver.exe");
driver = new FirefoxDriver();
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testGooglePageTitleInFirefoxBrowser() {
driver.navigate().to("http://www.google.com");
String strPageTitle = driver.getTitle();
System.out.println("Page title: - " + strPageTitle);
Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match");
}
@AfterTest
public void tearDown() throws InterruptedException {
driver.quit();
}
}
No comments:
Post a Comment