Wednesday, 9 August 2017

Code Example - Firefox Set Home Page

package com.practiceCode;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;


/**
 * @Blog Name : Selenium Code Example
 * @author Deepak Gupta
 * @Created Date 9-08-2017
 *
 */

public class FirefoxSetHomePage {

WebDriver driver;

@Test
public void testFireFoxProfile() throws InterruptedException {

System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "/drivers/geckodriver.exe");
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.startup.homepage", "http://www.google.com");
driver = new FirefoxDriver(profile);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.id("lst-ib")).sendKeys("100");

}

@AfterTest
public void end() throws InterruptedException {
Thread.sleep(2000);
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...