Mozialla Firefox SSL or all certificate error and page synchronization issue while navigating any url with security or without security | Selenium Webdriver Tutorial with c# |Selenium C# training

Selenium C# Training Forum

Mozialla Firefox SSL or all certificate error and page synchronization issue while navigating any url with security or without security

A
AMIT GUPTA Post on 22/08/2019

Dear Team,

 

While trying to execute script in Mozilla Firefox , i am getting SSL or certificate validation issue so i have developed my own code but it is not working with any security url and also got page synchronization issue but when i tried to run the code with debugging concept  line by line , it is working fine but in chrome browser there is no problem for security certificate and page synchronization . Could please assist me for running code smoothly for resolving security certificate error with any url and also page synchronization issue for any browser type because after giving implicit wait,explicit wait and thread.sleep method , my execution is not successfully completed all times except chrome browser?

 

First code :-

public void OpenBrowser(string driverType)

        {

            string browserdrivers = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            browserdrivers = Path.Combine(browserdrivers, "Drivers");

 

            if (driverType.Equals("Mozilla"))

            {

               

 

                FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(browserdrivers, "geckodriver.exe");

 

                string firefoxpath = null;

           

                bool OSbit = Environment.Is64BitOperatingSystem;

                //validate if operating system 64 bits in running environment

                if (OSbit == true)

                {

                    // firefoxpath = System.Environment.ExpandEnvironmentVariables(@"%systemdrive%\Program Files\Mozilla Firefox\firefox.exe");

                   ///recommended path for 64 bit

                     firefoxpath = @"C:\Program Files\Mozilla Firefox\firefox.exe";

                }

 

                else

                {

                   // firefoxpath = "@"+Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)+"\\Mozilla Firefox\\firefox.exe";

                     firefoxpath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";

                }

                service.FirefoxBinaryPath = firefoxpath;

 

                FirefoxProfile fp = new FirefoxProfile();

                FirefoxProfileManager manager = new FirefoxProfileManager();

                fp = manager.GetProfile("default");

                fp.SetPreference("dom.webnotifications.enabled", false);

               // fp.SetPreference("webdriver_assume_untrusted_issuer", true);

 

                fp.AcceptUntrustedCertificates = true;

                fp.AssumeUntrustedCertificateIssuer = false;

                FirefoxOptions options = new FirefoxOptions();

               // options.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe";

                options.BrowserExecutableLocation = firefoxpath;

                options.Profile = fp;

                this.Driver = new FirefoxDriver(service, options, TimeSpan.FromSeconds(20));

                Thread.Sleep(3000);

                this.Driver.Manage().Window.Maximize();

                this.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

 

            }

 

}

 

        public void Navigate(string url)

        {

            this.Driver.Url = url;

            Thread.Sleep(2000);

            this.Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

        }

 

Second code:-

   public void OpenBrowser(string driverType)

        {

            string browserdrivers = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            browserdrivers = Path.Combine(browserdrivers, "Drivers");

 

            if (driverType.Equals("Mozilla"))

            {

                FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(browserdrivers, "geckodriver.exe");

 

                FirefoxProfile profile = new FirefoxProfile();

                FirefoxProfileManager manager = new FirefoxProfileManager();

                FirefoxOptions options = new FirefoxOptions();

                options.Profile = profile;

                FirefoxDriver driver = new FirefoxDriver(options);

                this.Driver = new FirefoxDriver(service, options, TimeSpan.FromSeconds(20));

}

}

thanks for giving valuable time to hear me and assist me for small challenges.

 

Thanks

Amit G