How Selenium webdriver use existing firefox profile ?

by Selenium Trainer

in Blog, SELENIUM WEB DRIVER, Version1

Open firefox based on firefox profile using FirefoxProfile class Open firefox based on firefox profile using FirefoxProfile class

 

  • Create object of Class ProfilesIni
  • Call Method getProfile of Class ProfilesIni
  • Which return a object of the type Class FirefoxProfile
  • So Create new Class FirefoxProfile object and assign to it.

 

FF profile How it works

[sourcecode language="java"]
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

public class testFirefoxProfile {
public static void main(String[] args) {

//Class ProfilesIni details -> http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
ProfilesIni allProfiles = new ProfilesIni();

//Class FirefoxProfile -> http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
// Use FirefoxProfile Constructor
FirefoxProfile myProfile = allProfiles.getProfile("MyTestProfile");

WebDriver myDriver = new FirefoxDriver(myProfile);

myDriver.get("http://twitter.com");

System.out.println("What is my URL —————>" + myDriver.getCurrentUrl());

System.out.println("What is my Page title ———–>" + myDriver.getTitle());

System.out.println("");
myDriver.quit();

}

}

[/sourcecode]

Previous post:

Next post: