1

I tried to load profile by path string but it's not working.

FirefoxOptions options = new FirefoxOptions();            
options.Profile = new FirefoxProfile(@"d:\firefox");
options.Profile.SetPreference("privacy.trackingprotection.enabled", true);
IWebDriver driver = new FirefoxDriver(options);

if add argument it's work but can't automate.

options.AddArguments("-profile", @"d:\firefox");
Mikev
  • 2,012
  • 1
  • 15
  • 27
mangovn
  • 364
  • 2
  • 12

1 Answers1

0

See this link: https://seleniumhq.github.io/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Firefox_FirefoxDriverService.htm

var driverService = FirefoxDriverService.CreateDefaultService(path)

Create an instance of the DriverService using a specified path exe.

After that you can create an instance of RemoteWebDriver with specified driver service:

var driver = new FirefoxDriver((FirefoxDriverService)driverService, (FirefoxOptions)options, TimeSpan.FromMinutes(2)); //third parameter is a command timeout
L.Zoffoli
  • 129
  • 3
  • 10
  • var driverService = FirefoxDriverService.CreateDefaultService(path); path mean FirefoxBinaryPath not Profile path. Thank you – mangovn Jun 13 '19 at 15:39
  • https://seleniumhq.github.io/selenium/docs/api/dotnet/html/M_OpenQA_Selenium_Firefox_FirefoxDriverService_CreateDefaultService_1.htm CreateDefaultService accept profile path @mangovn – L.Zoffoli Jun 13 '19 at 15:42
  • OpenQA.Selenium.DriverServiceNotFoundException: 'The file .......\bin\Debug\firefox_data\default\geckodriver.exe does not exist. The driver can be downloaded at https://github.com/mozilla/geckodriver/releases' – mangovn Jun 13 '19 at 15:52
  • What's a path value? ...\source\repos\buyer\buyer\bin\Debug\6vvzzarr.default\ ? – L.Zoffoli Jun 13 '19 at 15:52
  • ...\source\repos\buyer\buyer\bin\Debug\6vvzzarr.default\ is profile path – mangovn Jun 13 '19 at 15:53
  • documents said Parameters driverPath Type: System.String The directory containing the Firefox driver executable. – mangovn Jun 13 '19 at 15:54
  • is geckodriver.exe into that path? – L.Zoffoli Jun 13 '19 at 15:58
  • i was tried copy geckodriver.exe into that path, working fine but can''t load profile. Thank – mangovn Jun 13 '19 at 15:59
  • old gecko driver just driver = new FirefoxDriver(profilepath) but they were removed. – mangovn Jun 13 '19 at 16:01