Reputation: 2643
I have the latest version of Firefox(62.0 32-bit), Selenium(3.14.0.0)and gecko driver(0.22.0 32-bit). I have code as follows:
var firefoxProfile = new FirefoxProfile("XXX");
FirefoxDriverService service =
FirefoxDriverService.CreateDefaultService("XXX", "geckodriver.exe");
service.FirefoxBinaryPath = "XXX";
driver = new FirefoxDriver(service, new FirefoxOptions {
BrowserExecutableLocation = "XXX",
Profile = firefoxProfile,
UseLegacyImplementation = false },
new TimeSpan(0, 1, 30));
However the final line fails due to the following error:
System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'C:\Users\XXX\AppData\Local\Temp\anonymous.5bbc89e65ae54c058b27b9027039414b.webdriver-profile.parentlock'.'
When you look in the directory, the "anonymous.5bbc89e65ae54c058b27b9027039414b.webdriver-profile" folder does not exist.
I can generate a folder by invoking the following code:
firefoxProfile.WriteToDisk();
However I'll still get the same error, just with a different "anonymous" folder after running the final line of my code.
I can get around the issue by enabling "UseLegacyImplementation" but this introduces other issues and is not optimal.
Looking around I don't see this message referenced anywhere, there is something referenced on Github, but it's in reference to the profile being ignored, not erroring.
I've had similar code working on older versions of the library and firefox, for some reason when I try to implement on a different machine with all the latest I experience this issue. Does anyone have any input on this?
Upvotes: 4
Views: 1494
Reputation: 471
I managed to reproduce your problem, but did the following and got rid of it.
I created a new profile from Firefox about:profiles
-> New profile Name = TestUser
Copied the location of this profile (Root Directory) and used it when creating the instance of FirefoxProfile
var firefoxProfile = new FirefoxProfile(@"C:\Users\[user]\AppData\Roaming\Mozilla\Firefox\Profiles\67fkrqcg.TestUser");
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\geckodriver-v0.22.0-win32", "geckodriver.exe");
service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
var driver = new FirefoxDriver(service, new FirefoxOptions
{
BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe",
Profile = firefoxProfile,
UseLegacyImplementation = false
},
new TimeSpan(0, 1, 30));
The error was thrown due to the method DeleteLockFiles
call which according to the documentation Deletes the lock files for a profile.
I suspect you forgot to create the profile and/or did not specify the correct path to it.
Upvotes: 2