1

I'm trying to use webdrivermanager library to load firefox driver in my selenium tests. I'm unable to load a specific firefox profile using this library. Here is what i'm trying to do:

FirefoxDriverManager.getInstance().setup() // To instantiate the firefox driver 

ProfilesIni Prof = new ProfilesIni();

FirefoxProfile profile = Prof.getProfile("C:\\Users\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\6xv9ndwh.SELENIUM");

WebDriver driver = new FirefoxDriver(profile);

But this instantiates a new driver and does not force the driver instantiated by firefoxdrivermanager to use the specific profile.

I tried using default gecko driver too that does not load the profile either. Here is the code that i'm trying:

System.setProperty("webdriver.gecko.driver", "C:\\geckodriver\\geckodriver-v0.20.0-win64\\geckodriver.exe");

ProfilesIni allProfiles = new ProfilesIni();

FirefoxProfile Profile = allProfiles.getProfile('default');

Profile.setAcceptUntrustedCertificates(true);

Profile.setAssumeUntrustedCertificateIssuer(false);

driver = new FirefoxDriver(Profile);

Can someone help me on this please?

2 Answers2

1

First of all create a new firefox profile steps for it are 1. Run this command firefox.exe -p in run window

enter image description here

It will show this dialog box create profile with new name and exit the window.

After that perform this command in webdriver

  System.setProperty("webdriver.firefox.marionette", "Path to the exe of firefox driver");
    ProfilesIni profile = new ProfilesIni();

    FirefoxProfile myprofile = profile.getProfile("UrProfile Name which u created");
    WebDriver driver = new FirefoxDriver(myprofile);

    driver.get("http://www.google.com");

Hope it may help u...

Dimple patel
  • 152
  • 1
  • 13
  • I tried this but since i'm using Gradle, it creates 2 new instances of the driver and also it throws null pointer exception - Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. – Balaji Venkatachalam Mar 26 '18 at 19:48
0

This worked for me (though not using webdrivermanager) for instantiating webdriver using Gradle:

 DesiredCapabilities capabilities = DesiredCapabilities.firefox();
 capabilities.setCapability("marionette", true);
 capabilities.setCapability("acceptInsecureCerts", true);
 driver = {new FirefoxDriver(capabilities)}