Wednesday, 9 August 2017

Code Example - Firefox Browser

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

Code Example - File Download By Robot Class In Firefox Browser

Exported from Notepad++ package com . practiceCode ; import java . awt . AWTException ; import java . awt . Robot ; import j...