How to create a fire fox profile and invoke that in webdriver
Creating firefox profile:
- In run type "firefox.exe -P"
- click on create profile.
- Follow the wizard which helps in creating the new profile.
- Copy the address of new profile which is created.
Invoking the profile when running the test script
- Create a public static method called pfirefox.
- Use this line in that method "FirefoxProfile pf = new FirefoxProfile(new File("Location of the newly created profile address."));
Note: For example if the newly created address is like this "C:\Mozilla\Firefox\Profiles\axgx9a31.profile". Then the address should be changed to "C:\\Mozilla\\Firefox\\Profiles\\axgx9a31.profile".
public class xyz{
public static FirefoxProfile pf(){
FirefoxProfile pf = new FirefoxProfile(new File("C:\\Mozilla\\Firefox\\Profiles\\axgx9a31.profile"));
System.out.println("::::::::: New profile");
return pf;
}
}
When defining driver
WebDriver driver = new FirefoxDriver(classname.method name());
i.e. WebDriver driver = new FirefoxDriver(xyz.pf());
Comments