public static void EnableFileDownloading(this OperaOptions options, string downloadDir)
 {
     options.AddLocalStatePreference("profile.default_content_settings.popups", 0);
     options.AddLocalStatePreference("download.prompt_for_download", "false");
     options.AddLocalStatePreference("download.default_directory", downloadDir);
     options.AddLocalStatePreference("plugins.plugins_disabled", new[] { "Chrome PDF Viewer" });
 }
        public IWebDriver Create(DriverType driverType)
        {
            switch (driverType)
            {
            case DriverType.Chrome:
            {
                var options = new ChromeOptions();
                options.AddArguments("--no-sandbox", "--disable-infobars", "--disable-save-password-bubble");
                return(new ChromeDriver(options));
            }

            case DriverType.Edge:
            {
                var options = new EdgeOptions
                {
                    PageLoadStrategy = PageLoadStrategy.Eager
                };
                return(new EdgeDriver(options));
            }

            case DriverType.Firefox:
            {
                var options = new FirefoxOptions
                {
                    AcceptInsecureCertificates = true
                };
                return(new FirefoxDriver(options));
            }

            case DriverType.InternetExplorer:
            {
                var options = new InternetExplorerOptions
                {
                    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                    InitialBrowserUrl  = "about:blank",
                    EnableNativeEvents = true,
                    IgnoreZoomLevel    = true
                };
                return(new InternetExplorerDriver(options));
            }

            case DriverType.Opera:
            {
                var options = new OperaOptions();
                options.AddArguments("--no-sandbox", "--disable-infobars", "--disable-save-password-bubble");
                options.BinaryLocation = @"C:\Program Files\Opera\launcher.exe";
                return(new OperaDriver(options));
            }

            case DriverType.Phantom:
            {
                return(new PhantomJSDriver());
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(driverType), driverType, null);
            }
            }
        }
Exemplo n.º 3
0
        private OperaOptions CreateOptions()
        {
            var options = new OperaOptions();

            if (BrowserSettings.Settings.IsRemoteRun())
            {
                options.AddAdditionalCapability("version", BrowserSettings.Settings.Remote.Version ?? Constants.DEFAULT_VERSION, true);
                options.AddAdditionalCapability("enableVNC", true, true);
                options.AddAdditionalCapability("platform", BrowserSettings.Settings.Remote.Platform ?? Constants.DEFAULT_PLATFORM, true);
                options.AddAdditionalCapability("name", BrowserSettings.Settings.Remote.Project ?? Constants.DEFAULT_PROJECT, true);
            }

            if (BrowserSettings.Settings.IsOptions())
            {
                options.AddArguments(BrowserSettings.Settings.Options);
            }

            if (!BrowserSettings.Settings.IsBinaryPath())
            {
                options.BinaryLocation = BrowserSettings.Settings.BinaryLocation;
            }

            if (BrowserSettings.Settings.CheckCapability())
            {
                options.AddCapabilities(BrowserSettings.Settings.Capabilities);
            }

            return(options);
        }
Exemplo n.º 4
0
        public void StartHeadless(Browser browser)
        {
            var argument = "-headless";

            switch (browser)
            {
            case Browser.Chrome:
                ChromeOptions optionsChrome = new ChromeOptions();
                optionsChrome.AddArgument(argument);
                WrappedDriver = new ChromeDriver(Environment.CurrentDirectory, optionsChrome);
                break;

            case Browser.Firefox:
                FirefoxOptions optionsFirefox = new FirefoxOptions();
                optionsFirefox.AddArgument(argument);
                WrappedDriver = new FirefoxDriver(Environment.CurrentDirectory, optionsFirefox);
                break;

            case Browser.Opera:
                OperaOptions optionsOpera = new OperaOptions();
                optionsOpera.AddArgument(argument);
                WrappedDriver = new OperaDriver(Environment.CurrentDirectory, optionsOpera);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(browser), browser, null);
            }
            _webDriverWait = new WebDriverWait(WrappedDriver, TimeSpan.FromSeconds(30));
        }
Exemplo n.º 5
0
        public static IWebDriver BrowserStarter()
        {
            var browser = ConfigurationManager.AppSettings["browser"];

            switch (browser.ToLower())
            {
            case "chrome":
                OperaOptions opt = new OperaOptions();
                opt.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
                wd = new ChromeDriver(@"C:\Users\partha\Documents\visual studio 2017\Projects\Selenium\Nunit\bin\Debug\");
                break;

            case "firefox":
                FirefoxDriverService serv = FirefoxDriverService.CreateDefaultService(@"C:\Users\partha\Documents\visual studio 2017\Projects\Selenium\Nunit\bin\Debug\", "geckodriver.exe");
                serv.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
                wd = new FirefoxDriver(serv);
                break;

            case "opera":
                OperaOptions op = new OperaOptions();
                op.BinaryLocation = @"C:\Program Files\Opera\launcher.exe";
                wd = new OperaDriver(@"C:\Users\partha\Documents\visual studio 2017\Projects\Selenium\Nunit\bin\Debug\");
                break;

            case "ie":
                break;
            }
            wd.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(120);
            wd.Manage().Window.Maximize();
            return(wd);
        }
Exemplo n.º 6
0
        private IWebDriver InitialDriver(BrowserType browser = BrowserType.Chrome)
        {
            // We are at path 'projectDirectory\\src\\Part-A-Worker'
            var os = WhatOSAmI();
            var toProjectDirectory = "..\\";
            var driverPath         = $"{toProjectDirectory}\\web-drivers\\chrome\\{os}\\";

            if (os == "linux")
            {
                driverPath = $"./{driverPath.Replace('\\', '/')}";
            }

            switch (browser)
            {
            case BrowserType.Chrome:
                var options = new ChromeOptions();
                // options.AddArguments("headless");
                // options.AddArgument("port=49675");
                // options.BrowserVersion = "81.0.4044.20";
                // options.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome Beta\Application";
                // options.AddArgument("chromever=81.0.4044.20");
                options.AddArgument("no-sandbox");
                options.AddArgument("--no-sandbox");
                return(new ChromeDriver(driverPath, options));

            case BrowserType.Opera:
                var oOptions = new OperaOptions();
                // options.AddArguments("headless");
                return(new OperaDriver(driverPath, oOptions));
            }

            throw new System.Exception();
        }
Exemplo n.º 7
0
        static IWebDriver GetDriver(Action <DriverOptions> driverOptions)
        {
            var options = new OperaOptions();

            driverOptions?.Invoke(options);
            return(new SeleniumOperaDriver(AppDomain.CurrentDomain.BaseDirectory, options));
        }
Exemplo n.º 8
0
        private static Task <IWebDriver> GetOperaDriverAsync()
        {
            var options = new OperaOptions()
            {
                AcceptInsecureCertificates = true,
                UnhandledPromptBehavior    = UnhandledPromptBehavior.Accept
            };

            var service = OperaDriverService.CreateDefaultService(
                Path.Combine(
                    Environment.CurrentDirectory,
                    "Drivers"),
                Path.Combine(
                    Environment.GetFolderPath(
                        Environment.SpecialFolder.LocalApplicationData),
                    "Programs",
                    "Opera",
                    "launcher.exe"));

            service.HostName = "127.0.0.1";

            var driver = new OperaDriver(
                service,
                options);

            return(Task.FromResult <IWebDriver>(driver));
        }
Exemplo n.º 9
0
        public static IWebDriver CreateInstance(BrowserType browserType, string hubUrl)
        {
            IWebDriver driver   = null;
            TimeSpan   timeSpan = new TimeSpan(0, 3, 0);

            switch (browserType)
            {
            case BrowserType.Chrome:
                ChromeOptions chromeOptions = new ChromeOptions();
                driver = GetWebDriver(hubUrl, chromeOptions.ToCapabilities());
                break;

            case BrowserType.Edge:
                EdgeOptions options = new EdgeOptions();
                driver = GetWebDriver(hubUrl, options.ToCapabilities());
                break;

            case BrowserType.Firefox:
                FirefoxOptions firefoxOptions = new FirefoxOptions();
                driver = GetWebDriver(hubUrl, firefoxOptions.ToCapabilities());
                break;

            case BrowserType.Opera:
                OperaOptions operaOptions = new OperaOptions();
                driver = GetWebDriver(hubUrl, operaOptions.ToCapabilities());
                break;
            }

            return(driver);
        }
Exemplo n.º 10
0
        private static RemoteWebDriver StartOperaDriver(DriverSettings settings)
        {
            var options = new OperaOptions();

            settings.Capabilities?.ForEach(cap => options.AddAdditionalCapability(cap.Key, cap.Value));
            if (!string.IsNullOrEmpty(settings.BrowserBinaryPath))
            {
                options.BinaryLocation = settings.BrowserBinaryPath;
            }
            if (!string.IsNullOrEmpty(settings.Proxy))
            {
                options.Proxy = new Proxy {
                    HttpProxy = settings.Proxy
                }
            }
            ;
            if (settings.BrowserBinaryPath != null)
            {
                options.BinaryLocation = settings.BrowserBinaryPath;
            }
            if (settings.CmdArgs != null)
            {
                options.AddArguments(settings.CmdArgs);
            }
            if (settings.Extensions != null)
            {
                options.AddExtensions(settings.Extensions);
            }
            return(new OperaDriver(options));
        }
        private OperaOptions CreateOperaOptions()
        {
            var operaOptions = new OperaOptions();

            operaOptions.BinaryLocation = ApplicationHelper.GetOperaBinaryLocation();
            operaOptions.EnableFileDownloading(this.config.DownloadDirPath);
            return(operaOptions);
        }
Exemplo n.º 12
0
        public void Initialize()
        {
            OperaDriverService service = OperaDriverService.CreateDefaultService(@"E:/C#/Binary/Binary_Testing/"); //path to OperaDriver
            OperaOptions       options = new OperaOptions();

            options.BinaryLocation = @"C:/Program Files/Opera/launcher.exe"; //path to my Opera browser
            driver = new OperaDriver(service, options);
        }
Exemplo n.º 13
0
        static IWebDriver MakeDriver()
        {
            OperaOptions opera = new OperaOptions();

            opera.BinaryLocation = @"C:\Program Files\Opera\launcher.exe";

            return(new OperaDriver(opera));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Использование оперы в качестве браузера
        /// </summary>
        public void InitializeOperaDriver()
        {
            OperaOptions options = new OperaOptions();

            options.BinaryLocation = settings.OperaPath;
            options.AddArgument("user-data-dir=" + Directory.GetCurrentDirectory() + @"\opera");
            options.AddArgument("private");
            driver = new OperaDriver(options);
            driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(40);
        }
Exemplo n.º 15
0
        public IWebDriver GetDriver()
        {
            var currentDirectory = Directory.GetCurrentDirectory();
            var options          = new OperaOptions();

            options.BinaryLocation = @"C:\Program Files\Opera\launcher.exe";
            var service = OperaDriverService.CreateDefaultService($"{currentDirectory}\\drivers\\operadriver_win64\\");

            return(new OpenQA.Selenium.Opera.OperaDriver(service, options, TimeSpan.FromMinutes(3)));
        }
        /// <summary>
        /// Instantiates a RemoteWebDriver instance based on the browser passed to this method. Opens the browser and maximizes its window.
        /// </summary>
        /// <param name="browser">The browser to get instantiate the Web Driver for.</param>
        /// <param name="browserProfilePath">The folder path to the browser user profile to use with the browser.</param>
        /// <returns>The RemoteWebDriver of the browser passed in to the method.</returns>
        public static RemoteWebDriver CreateDriverAndMaximize(string browser, string browserProfilePath = "")
        {
            // Create a webdriver for the respective browser, depending on what we're testing.
            RemoteWebDriver driver = null;

            switch (browser)
            {
            case "opera":
            case "operabeta":
                OperaOptions oOption = new OperaOptions();
                oOption.AddArgument("--disable-popup-blocking");
                oOption.AddArgument("--power-save-mode=on");
                // TODO: This shouldn't be a hardcoded path, but Opera appeared to need this speficied directly to run well
                oOption.BinaryLocation = @"C:\Program Files (x86)\Opera\launcher.exe";
                if (browser == "operabeta")
                {
                    // TODO: Ideally, this code would look inside the Opera beta folder for opera.exe
                    // rather than depending on flaky hard-coded version in directory
                    oOption.BinaryLocation = @"C:\Program Files (x86)\Opera beta\38.0.2220.25\opera.exe";
                }
                driver = new OperaDriver(oOption);
                break;

            case "firefox":
                driver = new FirefoxDriver();
                break;

            case "chrome":
                ChromeOptions option = new ChromeOptions();
                option.AddUserProfilePreference("profile.default_content_setting_values.notifications", 1);

                if (!string.IsNullOrEmpty(browserProfilePath))
                {
                    option.AddArgument("--user-data-dir=" + browserProfilePath);
                }

                driver = new ChromeDriver(option);
                break;

            default:
                // Warning: this blows away all Microsoft Edge data, including bookmarks, cookies, passwords, etc
                EdgeDriverService svc = EdgeDriverService.CreateDefaultService();
                driver = new EdgeDriver(svc);
                Thread.Sleep(2000);
                HttpClient client = new HttpClient();
                client.DeleteAsync($"http://localhost:{svc.Port}/session/{driver.SessionId}/ms/history").Wait();
                break;
            }

            driver.Manage().Window.Maximize();

            Thread.Sleep(1000);

            return(driver);
        }
Exemplo n.º 17
0
        public void CreateMessage_OperaOptions_ReturnString()
        {
            var options = new OperaOptions();

            options.AddArguments(new List <string> {
                "--start-maximized", "--ignore-certificate-errors"
            });
            var str = options.CreateMessage().Replace("\n", "").Replace("\r", "").RemoveWhitespace();

            str.Should().Be(operaOptions);
        }
Exemplo n.º 18
0
        public static IWebDriver GetInstance()
        {
            BaseClass.Logger.Information("Initialize Opera");
            _operaOptions = new OperaOptions {
                BinaryLocation = @"C:\Program Files\Opera\launcher.exe"
            };

            _instance = new OperaDriver(_operaOptions);
            _instance.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(5);
            _instance.Manage().Window.Maximize();
            return(_instance);
        }
Exemplo n.º 19
0
        public void AbrirInstancia()
        {
            string navegador = ConfigurationManager.AppSettings["NavegadorDefault"].ToString();
            string nodeURL   = ConfigurationManager.AppSettings["IpHub"].ToString();
            string local     = ConfigurationManager.AppSettings["Local"].ToString();

            if (driver == null)
            {
                if (local.Equals("true"))
                {
                    ChromeOptions chrome = new ChromeOptions();
                    chrome.AddArgument("enable-automation");
                    chrome.AddArgument("--no-sandbox");
                    chrome.AddArgument("--disable-infobars");
                    chrome.AddArgument("--disable-dev-shm-usage");
                    chrome.AddArgument("--disable-browser-side-navigation");
                    chrome.AddArgument("--disable-gpu");
                    chrome.AddArgument("--window-size=1920,1080");
                    chrome.AddArgument("--lang=pt-BR");
                    chrome.PageLoadStrategy = PageLoadStrategy.Normal;
                    driver = new ChromeDriver(chrome);
                    //driver.Manage().Window.Maximize();
                }
                else
                {
                    switch (navegador)
                    {
                    case ("firefox"):
                        FirefoxOptions firefox = new FirefoxOptions();
                        driver = new RemoteWebDriver(new Uri(nodeURL), firefox.ToCapabilities());
                        driver.Manage().Window.Maximize();
                        break;

                    case ("chrome"):
                        ChromeOptions chrome = new ChromeOptions();
                        driver = new RemoteWebDriver(new Uri(nodeURL), chrome.ToCapabilities());
                        driver.Manage().Window.Maximize();
                        break;

                    case ("opera"):
                        OperaOptions opera = new OperaOptions();
                        opera.BinaryLocation = "@" + ConfigurationManager.AppSettings["PatchOperaExe"].ToString();;
                        driver = new RemoteWebDriver(new Uri(nodeURL), opera.ToCapabilities());
                        driver.Manage().Window.Maximize();
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
                driver.Navigate().GoToUrl(ConfigurationManager.AppSettings["URL"].ToString());
            }
        }
Exemplo n.º 20
0
        public OperaBuilder()
        {
            string driverName = "OperaDriver";

            _options    = new OperaOptions();
            _driverPath = null;

            SetArguments(WebDriverConfigManager.GetDriverArgument(driverName));
            SetBinaryLocation(WebDriverConfigManager.GetDriverConfiguration(driverName, WebDriverConfigParameters.BinaryLocation));
            SetBrowserVersion(WebDriverConfigManager.GetDriverConfiguration(driverName, WebDriverConfigParameters.BrowserVersion));
            SetPlatformName(WebDriverConfigManager.GetDriverConfiguration(driverName, WebDriverConfigParameters.PlatformName));
        }
Exemplo n.º 21
0
        private static IWebDriver CreateDesktopWebDriver()
        {
            DesiredCapabilities capabilities;

            var browser = Config.Settings.BrowserStackSettings.BsBrowser;

            switch (browser)
            {
            case "Chrome":
                var chromeOptions = new ChromeOptions();
                chromeOptions.AddArguments("--disable-popup-blocking");
                capabilities = chromeOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Chrome");
                return(CreateRemoteWebDriver(capabilities));

            case "Firefox":
                FirefoxOptions firefoxOptions = new FirefoxOptions();
                capabilities = firefoxOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Firefox");
                return(CreateRemoteWebDriver(capabilities));

            case "IE":
                InternetExplorerOptions ieOptions = new InternetExplorerOptions();
                capabilities = ieOptions.ToCapabilities() as DesiredCapabilities;
                capabilities.SetCapability("browserstack.ie.enablePopups", "true");
                SetCapabilities(capabilities, "IE");
                return(CreateRemoteWebDriver(capabilities));

            case "Edge":
                var edgeOptions = new EdgeOptions();
                edgeOptions.PageLoadStrategy = PageLoadStrategy.Eager;
                capabilities = edgeOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Edge");
                return(CreateRemoteWebDriver(capabilities));

            case "Safari":
                SafariOptions safariOptions = new SafariOptions();
                capabilities = safariOptions.ToCapabilities() as DesiredCapabilities;
                capabilities.SetCapability("browserstack.safari.enablePopups", "true");
                SetCapabilities(capabilities, "Safari");
                return(CreateRemoteWebDriver(capabilities));

            case "Opera":
                OperaOptions operaOptions = new OperaOptions();
                capabilities = operaOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Opera");
                return(CreateRemoteWebDriver(capabilities));

            default:
                throw new ArgumentOutOfRangeException("'Browser' value: " + browser);
            }
        }
Exemplo n.º 22
0
        public static void CreateInstance()
        {
            //criado um appconfig com a configuração desejada
            string navegador = ConfigurationManager.AppSettings["NavegadorDefault"].ToString();
            string local     = ConfigurationManager.AppSettings["Local"].ToString();
            string hubURL    = ConfigurationManager.AppSettings["Hublink"].ToString();

            if (INSTANCE == null)
            {
                switch (local)
                {
                case ("true"):     //Execução Local
                    ChromeOptions chromeOptions = new ChromeOptions();
                    INSTANCE = new ChromeDriver(chromeOptions);
                    INSTANCE.Manage().Window.Maximize();
                    break;

                case ("false"):     //Execução Grid
                    switch (navegador)
                    {
                    case ("firefox"):
                        FirefoxOptions firefox = new FirefoxOptions();
                        INSTANCE = new RemoteWebDriver(new Uri(hubURL), firefox.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    case ("chrome"):
                        ChromeOptions chrome = new ChromeOptions();
                        INSTANCE = new RemoteWebDriver(new Uri(hubURL), chrome.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    case ("opera"):
                        OperaOptions opera = new OperaOptions();
                        opera.BinaryLocation = "@" + ConfigurationManager.AppSettings["PathOperaExe"].ToString();
                        INSTANCE             = new RemoteWebDriver(new Uri(hubURL), opera.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    case ("edge"):
                        EdgeOptions edge = new EdgeOptions();
                        INSTANCE = new RemoteWebDriver(new Uri(hubURL), edge.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                    break;
                }
            }
        }
Exemplo n.º 23
0
        //OperaDriverPath is where the firefox driver is.
        //OperaBrowserPath is where the opera browser is installed.
        //OperaDriverName is the name of the opera driver with its' extension (ex: .exe)
        public static IWebDriver InvokeOpera(String OperaBrowserPath = @"C:\Program Files\Opera\51.0.2830.55\opera.exe",
                                             String OperaDriverPath  = @"C:\Selenium\Browsers drivers\",
                                             String OperaDriverName  = "operadriver.exe")
        {
            InbrowserObject = null;
            OperaDriverService operaDriverService =
                OperaDriverService.CreateDefaultService(OperaDriverPath, "operadriver.exe");
            OperaOptions options = new OperaOptions();

            options.BinaryLocation = (OperaBrowserPath);
            InbrowserObject        = new OperaDriver(operaDriverService, options);
            return(InbrowserObject);
        }
Exemplo n.º 24
0
 public static void Setup(TestContext testContext)
 {
     var options = new OperaOptions();
     options.BinaryLocation = OperaBinary;
     Driver = new QxWebDriver(new OperaDriver(options));
     Driver.Manage().Window.Maximize();
     Cache.Clear();
     WisejTests.Driver = Driver;
     #if !DEBUGJS
     Driver.Url = "http://localhost:7185/Default.html";
     #else
     Driver.Url = "http://localhost:7185/Debug.html";
     #endif
 }
Exemplo n.º 25
0
            public void DriverPath()
            {
                if (typeof(TPage) == typeof(OperaDriver))
                {
                    OperaOptions opera = new OperaOptions();
                    opera.BinaryLocation = @"C:\Program Files\Opera\launcher.exe";

                    driver = new OperaDriver(opera);
                }
                else
                {
                    driver = new TPage();
                }
            }
Exemplo n.º 26
0
        public void OpenAppOpera()
        {
            OperaDriverService service = OperaDriverService.CreateDefaultService("C:\\Users\\OChernovolyk\\source\\operadriver", "operadriver.exe");
            var operaOptions           = new OperaOptions
            {
                BinaryLocation      = "C:\\Users\\OChernovolyk\\AppData\\Local\\Programs\\Opera\\62.0.3331.72\\opera.exe",
                LeaveBrowserRunning = false
            };

            driver = new OperaDriver(service, operaOptions);


            driver.Url = "https://www.google.com.ua/";
            driver.Close();
        }
Exemplo n.º 27
0
        public OperaOptions GetOptions(OperaConfiguration configuration)
        {
            var options = new OperaOptions()
            {
                BinaryLocation      = configuration.BinaryLocation,
                DebuggerAddress     = configuration.DebuggerAddress,
                LeaveBrowserRunning = configuration.LeaveBrowserRunning,
                MinidumpPath        = configuration.MinidumpPath,
                Proxy = configuration.Proxy
            };

            configuration.SetAdditionalCapability(options);

            return(options);
        }
Exemplo n.º 28
0
        private void OperaDriverInitialize()
        {
            string browserInstallationDir = UPG.Properties.Settings.Default.BrowserInstallionDir;

            if (browserInstallationDir != "Default")
            {
                OperaOptions options = new OperaOptions();
                options.BinaryLocation = browserInstallationDir;
                driver = new OperaDriver(options);
            }

            else
            {
                driver = new OperaDriver();
            }
        }
Exemplo n.º 29
0
        protected override IWebDriver DoBuildAndGetWebDriver(BrowserConfig browserConfig)
        {
            OperaDriverService operaDriverService = OperaDriverService.CreateDefaultService(browserConfig.WebDriverPath);
            OperaOptions       operaOptions       = new OperaOptions();

            operaOptions.BinaryLocation = browserConfig.WebDriverPath + "opera.exe";

            if (browserConfig.BrowserOptions != null)
            {
                operaOptions.AddArguments(browserConfig.BrowserOptions);
            }

            IWebDriver webDriver = new OperaDriver(operaDriverService, operaOptions);

            return(webDriver);
        }
Exemplo n.º 30
0
        public static void Remote(string navegador)
        {
            string Iphub = ConfigurationManager.AppSettings["IpHub"].ToString();

            switch (navegador)
            {
            case ("firefox"):
                FirefoxOptions firefox = new FirefoxOptions();
                firefox.SetPreference("intl.accept_languages", "pt-BR");
                firefox.AddArgument("-width");
                firefox.AddArgument("1920");
                firefox.AddArgument("-height");
                firefox.AddArgument("1080");

                INSTANCE = new RemoteWebDriver(new Uri(Iphub), firefox.ToCapabilities());
                //INSTANCE.Manage().Window.Maximize();
                break;

            case ("chrome"):
                ChromeOptions chrome = new ChromeOptions();
                chrome.AddArgument("no-sandbox");
                chrome.AddArguments("headless");
                chrome.AddArgument("--allow-running-insecure-content");
                chrome.AddArgument("--lang=pt-BR");
                chrome.AddArgument("--window-size=1920,1080");

                INSTANCE = new RemoteWebDriver(new Uri(Iphub), chrome.ToCapabilities());
                //INSTANCE.Manage().Window.Maximize();
                break;

            case ("ie"):
                InternetExplorerOptions ie = new InternetExplorerOptions();
                INSTANCE = new RemoteWebDriver(new Uri(Iphub), ie.ToCapabilities());
                //INSTANCE.Manage().Window.Maximize();
                break;

            case ("opera"):
                OperaOptions opera = new OperaOptions();
                opera.BinaryLocation = "/usr/bin/opera";
                INSTANCE             = new RemoteWebDriver(new Uri(Iphub), opera.ToCapabilities());
                INSTANCE.Manage().Window.Maximize();
                break;

            default:
                throw new NotImplementedException();
            }
        } //fim void