Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open specified profile Firefox with Selenium 2 Webdriver?

Tags:

java

selenium

When I use default profile starts without problem. But when i starts with custom profile, firefox starts but stays "blocked". The process remains active consuming 31MB of RAM, but never start. Only start if I killed the process, then starts and works fine with selenium.

I use Windows 7, Firefox 25.0.1 and selenium-server-standalone-2.38.0.jar ¿Maybe problems with compatibility of versions?

This is the code to open the profile:

FirefoxProfile profile = new FirefoxProfile(new File("C:/Users/UserTest/AppData/Roaming/Mozilla/Firefox/Profiles/tydtn9km.testprofile"));                  
WebDriver driver = new FirefoxDriver(profile);

Edit: This is my actual code

package org.openqa.selenium.example;

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 Main  {
    public static void main(String[] args) {
        ProfilesIni profile = new ProfilesIni();
        FirefoxProfile ffprofile = profile.getProfile("Other");
        WebDriver driver = new FirefoxDriver(ffprofile);
        driver.get("http://google.com");
    }
}

Edit 2: Resolved The problem ocurred because my Firefox profile is located in another partition, and Firefox in the other partition.

like image 794
user3095228 Avatar asked Dec 12 '13 12:12

user3095228


People also ask

How do I get Firefox to open a specific profile?

Right-click on the desktop shortcut and select Properties. Enter -P “profile-name” at the end of the Target box. Click the OK button. Double-click on the desktop shortcut to open Firefox with a specific profile.

How do I have two Firefox profiles open at the same time?

--------------------------------- -------------------------- To get a 2nd Profile to launch while the first Profile is already running, you need to use the command line switch of '''-no -remote'''. That tells Firefox to ignore the already running '''firefox.exe''' process.

What is the use of Firefox profile in Selenium WebDriver?

Firefox profiles include custom preferences that you would like to simulate an environment for your test script. For example, you might want to create a profile that sets preferences to handle the download popup programmatically during your test run.


1 Answers

I have been using it like this:

First, create a Firefox profile and name it somehow you know. E.g. SELENIUM

Then initialize your profile:

ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);
like image 196
Pavel Janicek Avatar answered Sep 26 '22 01:09

Pavel Janicek