1

I am trying to connect to profile, its successfully connect to custom firefox profile, but the problem after that is command FirefoxDriver driver = new FirefoxDriver(options); no more works, works only if i remove options then no custom profile.

the before last line returns error OpenQA.Selenium.WebDriverException: 'Process unexpectedly closed with status 0' or The HTTP request to the remote WebDriver timed out after 60 seconds, it only works if I remove options inside FirefoxDriver: FirefoxDriver driver = new FirefoxDriver(options);

Also, doing options.AddArgument("-profile" + "C:\Users\Chill\AppData\Roaming\Mozilla\Firefox\Profiles\5k2mdm2k.myprofile"); instead of spliting the 2 arguments does not launch firefox in the right profile.

Or even options.AddArgument("no-sandbox") or options.AddArgument("-no-sandbox") or options.AddArgument("--no-sandbox") doesn't works, also --profile instead of -profile does not open the right profile also, here is my code anyway:

using System;
using OpenQA.Selenium;                  // nuget package name: Selenium.WebDriver
using OpenQA.Selenium.Firefox;          // nuget package name: Selenium.WebDriver.GeckoDriver

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            FirefoxOptions options = new FirefoxOptions();
            options.AddArgument("-profile");
            options.AddArgument(@"C:\Users\Chill\AppData\Roaming\Mozilla\Firefox\Profiles\5k2mdm2k.myprofile");    /* type about:profiles in firefox bar to create and manage firefox profiles, from there you will see which profile used, make sure to not use the default one and use root directory */
            FirefoxDriver driver = new FirefoxDriver(options);    /* code stops here and puts error after closing browser or waiting until it close itself after 60 sec */
            driver.Navigate().GoToUrl("https://www.google.com/");    /* can only reach this part of code if i remove turn FirefoxDriver(options); to FirefoxDriver(); on the line upper, but no more custom profile so */
        }
    }
}

Hope you can help im blocked on this step for 3 days

0

1 Answer 1

0

Using these nugget versions:

 <PackageReference Include="Selenium.Firefox.WebDriver" Version="0.27.0" />
 <PackageReference Include="Selenium.WebDriver" Version="4.0.0-beta4" />

This works for me:

using OpenQA.Selenium.Firefox;
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var options = new FirefoxOptions();
            var profile = new FirefoxProfile(@"C:\Users\CatalinR\AppData\Roaming\Mozilla\Firefox\Profiles\f9n067l1.default");

            options.Profile = profile;
            var driver = new FirefoxDriver(options);  
            driver.Navigate().GoToUrl("https://www.google.com/");   
        }
    }
}
6
  • I did this and there is no used profile when i go on about:profiles, which means it used a temp profile, can you maybe let me your firefox browser version and maybe try a different profile than default to see if the used one when firefox opens is the one corresponds to the path, if it works on about;profiles there should be written cannot be closed because its already used Commented Aug 26, 2021 at 22:08
  • I have firefox 91.0.2 (64-bit). I've create a new profile called Selenium and after the browser is opened., the about:profiles shows that its the default one. Commented Aug 26, 2021 at 22:14
  • i tried with this version and unfortunately doesn't work, do you have something like this: imgur.com/pu0arp0 Commented Aug 26, 2021 at 22:22
  • yep: imgur.com/a/DVqPlpU and video: imgur.com/a/5aghAxi Commented Aug 26, 2021 at 22:28
  • 1
    actually its not, if you look there is no text "This is the profile in use and it cannot be deleted." on the automation one while the normal one does which means its using a temp profile and not premade profile being used Commented Aug 26, 2021 at 22:31

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.