How to set Profile in FirefoxDriver, using geckodriver.exe in C#

1,543 views
Skip to first unread message

Piyush Ratnam

unread,
Dec 14, 2016, 6:49:07 AM12/14/16
to Selenium Users
Hi,

I am working on Selenium using C#. Since we are using  latest selenium3.0 .dlls with GeckoDriver. But Unfortunately we are unable to load the URL properly due to 
"Trusted Certificated Exception" in Firefox Driver. For that previously I used this below option to set the Profile and it was working fine.

FirefoxProfile ffprofile = new FirefoxProfile(@"C:\Users\piyushrx\AppData\Roaming\Mozilla\Firefox/Profiles\xq6onaon.Piyush");
driver = new FirefoxDriver(ffprofile);

But now, with the introduction of GeckoDriver, I am unable to do so. Here is why -

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"c:\CPP Files\", "geckodriver.exe");
driver = new FirefoxDriver(
service
);

Since, I can't pass to arguments in Firefoxdriver { i.e. 
FirefoxDriver(
service,
ffprofile 
); } which is no acceptable. 
Please let me know any solution for the same.



Regards,
Piyush Ratnam

                

Jeffrey Gary

unread,
Jan 11, 2017, 9:40:54 PM1/11/17
to Selenium Users
Here is the code that I use. I added the NuGet Package in Visual Studio so I don't need to specify the path of the geckodriver.exe.


case "Firefox":
                    if (Driver == null)
                    {
                        var driverService = FirefoxDriverService.CreateDefaultService();
                        driverService.HideCommandPromptWindow = true;
                        driverService.SuppressInitialDiagnosticInformation = true;
                        FirefoxOptions options = new FirefoxOptions();
                        options.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
                        driver = new FirefoxDriver(driverService, options, TimeSpan.FromSeconds(30));                        
                    }
                    break;

Regards,

Jeff Gary
Reply all
Reply to author
Forward
0 new messages