Open Profile Firefox with Selenium 3.0

0

Open a Firefox profile, start a web page in the browser.

I have this code that works for me to open firefox and go to the page but it does not do it in the specific profile. Could you please give me a help, I have exhausted all the tutorials. thanks

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class MM {

 public static void main(String[] args) {

    System.setProperty("webdriver.gecko.driver","C:\Users\MM\Desktop\fbc\lib\geckodriver.exe");

    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette",true);

    try{
        WebDriver driver = new FirefoxDriver();
        driver.get("https://google.com");
        Thread.sleep(1800);
    }catch(Exception e){
        System.out.println(e);
    }
 }
}
    
asked by Marcos Medina 05.11.2018 в 18:59
source

1 answer

0

Welcome Marcos,

In selenium 3 the profiles are added to the Firefox options as follows:

// Esta es tu linea que fija el gecko driver
System.setProperty("webdriver.gecko.driver","C:\Users\MM\Desktop\fbc\lib\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setCapability("marionette", true);
// Aqui puedes añadir todas las capabilities que necesites
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("myProfileName");
options.setCapability(FirefoxDriver.PROFILE, myprofile);
// Se crea el firefox driver con esas options
// Este ya es tu try catch
try{
WebDriver driver = FirefoxDriver(options);
driver.get("https://google.com");
Thread.sleep(1800);}
    
answered by 06.11.2018 в 17:31