Launch All Browser type successfully with ignore all SSL or insecure error | Selenium C# Forum
A
AMIT GUPTA Posted on 02/08/2019

Dear Team,

Could any team member provide valuable time to assist me for launching browser (FIREFOX, CHROME,EDGE , IE and safari ) that will ignore all SSL , insecure error and notification popup before navigating to url. I have placed my code to correct me for assist me with successfully execution.

  1. Firefox :- Getting SSL /Insecure certificate error (connection is not secure)
  2. Chrome :- Getting SSL /Insecure certificate error (connection is not secure)

3:- IE :- Getting SSL /Insecure certificate error (connection is not secure)

4:- EDGE :- Not launching Edge Browser and getting time out error { I didn’t get ‘MicrosoftWebDriver.exe’ release file according to my OS build number(17763.404).When I user latest ‘MicrosoftWebDriver.exe’ release(17134), it is throwing exception error while executing edge driver instance line.}

5:- safari :- not launching browser 

Edge browser error :-

 

Code :- using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using NUnit.Framework;

using OpenQA.Selenium;

using OpenQA.Selenium.Firefox;

using OpenQA.Selenium.IE;

 

using System.Configuration;

using System.Xml;

using AventStack.ExtentReports;

using System.IO;

using System.Net;

using OpenQA.Selenium.Chrome;

using OpenQA.Selenium.Support.UI;

using System.Threading;

using OpenQA.Selenium.Interactions;

using OpenQA.Selenium.Edge;

using  OpenQA.Selenium.Safari;

 

namespace TestingPractice.Services

{

    public class WebDriverService

    {

        public IWebDriver Driver { get; set; }

        public static DateTime dt = DateTime.Now;

        public static String strWebBrowser;

        public ExtentReports rep;

        public ExtentTest test;

        public static By by;

 

        public void OpenBrowser(string driverType)

        {

            if (driverType.Equals("Mozilla"))

            {

 

                FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(ConfigurationManager.AppSettings["GekoDriverPath"], "geckodriver.exe");

 

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

 

                FirefoxProfile fp = new FirefoxProfile();

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

                fp.AcceptUntrustedCertificates = true;

                fp.AssumeUntrustedCertificateIssuer = false;

                FirefoxOptions options = new FirefoxOptions();

                options.Profile = fp;

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

 

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

            }

            else if (driverType.Equals("Chrome"))

            {

                this.Driver = new ChromeDriver(ConfigurationManager.AppSettings["ChromeDriverPath"]);

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

            }

   else if (driverType.Equals("Safari"))

            {

                this.Driver = new SafariDriver();

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

            }

            else if (driverType.Equals("IE"))

            {

                this.Driver = new InternetExplorerDriver(ConfigurationManager.AppSettings["IEDriverPath"]);

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

 

            }

            else if (driverType.Equals("EDGE"))

            {

                //EdgeDriverService edgeDriverService;

 

                //                case BrowserType.Edge:

                //    EdgeDriverService edgeDriverService;

                //EdgeOptions edgeOptions = GetEdgeOptions(out edgeDriverService);

                //driver = new EdgeDriver(edgeDriverService, edgeOptions);

                //break;

 

                //EdgeOptions edgeOptions = GetEdgeOptions(out edgeDriverService);

                //this.Driver = new EdgeDriver(edgeDriverService, edgeOptions);

                EdgeOptions options = new EdgeOptions();

             //   options.PageLoadStrategy = EdgePageLoadStrategy.Eager;

            this.Driver = new EdgeDriver(ConfigurationManager.AppSettings["EdgeDriverPath"], options);

              //  this.Driver = new EdgeDriver(ConfigurationManager.AppSettings["EdgeDriverPath"]);

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

 

            }

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

        }

        public void Navigate(string url)

        {

            this.Driver.Url = url;

        }

}