Beispiel #1
0
        private IWebDriver GetEdgeDriver()
        {
            EdgeOptions edgeOptions = new EdgeOptions();

            edgeOptions.UseChromium = true;
            edgeOptions.AddArguments("--start-maximized");
            var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            return(new EdgeDriver(outPutDirectory, edgeOptions));
        }
        public static EdgeOptions GetEdgeOptions(string lang, bool headless = false, PlatformType platformType = PlatformType.Any)
        {
            EdgeOptions options = new EdgeOptions();

            options.UseChromium = true;
            options.AddArguments("disable-gpu", $"--lang={lang}");
            if (headless)
            {
                options.AddArgument("headless");
            }
            SetPlatform(options, platformType);
            return(options);
        }
Beispiel #3
0
        public static IWebDriver CreateWebDriver(Browser browser, string pathDriver, bool headless)
        {
            IWebDriver webDriver = null;

            switch (browser)
            {
            case Browser.Chrome:
                var optionsChrome = new ChromeOptions();
                if (headless)
                {
                    optionsChrome.AddArgument("--headless");
                }

                webDriver = new ChromeDriver(pathDriver, optionsChrome);
                break;

            case Browser.Edge:
                var optionsEdge = new EdgeOptions
                {
                    PageLoadStrategy = PageLoadStrategy.Normal,
                    UseChromium      = true
                };

                if (headless)
                {
                    optionsEdge.AddArguments(
                        "--headless",
                        "--disable-gpu",
                        "--window-size=1920,1080",
                        "--disable-extensions",
                        "--proxy-server='direct://'",
                        "--proxy-bypass-list=*",
                        "--start-maximized");
                }

                webDriver = new EdgeDriver(pathDriver, optionsEdge);
                break;

            case Browser.Firefox:
                var optionsFirefox = new FirefoxOptions();
                if (headless)
                {
                    optionsFirefox.AddArgument("--headless");
                }

                webDriver = new FirefoxDriver(pathDriver, optionsFirefox);
                break;
            }

            return(webDriver);
        }
Beispiel #4
0
        public Portal(PortalConfiguration configuration)
        {
            _config = configuration;

            switch (_config.BrowserSettings.BrowserType)
            {
            case BrowserType.Chrome:
                var chromeOptions = new ChromeOptions();
                if (_config.BrowserSettings.Headless)
                {
                    chromeOptions.AddArguments("headless");
                }

                _driver = new ChromeDriver(chromeOptions);

                break;

            case BrowserType.Firefox:
                var firefoxOptions = new FirefoxOptions();
                if (_config.BrowserSettings.Headless)
                {
                    firefoxOptions.AddArguments("--headless");
                }

                _driver = new FirefoxDriver(firefoxOptions);

                break;

            case BrowserType.Edge:

                var edgeOptions = new EdgeOptions();
                edgeOptions.UseChromium = true;

                if (_config.BrowserSettings.Headless)
                {
                    edgeOptions.AddArguments("headless");
                }

                _driver = new EdgeDriver(edgeOptions);

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            //_driver = new FirefoxDriver();
            this.Navigate(_config.BaseUrl);
        }
Beispiel #5
0
        public void SetUp()
        {
            AtataContext.Configure().
            UseDriver(() =>
            {
                EdgeOptions options = new EdgeOptions
                {
                    UseChromium = true
                };

                options.AddArguments("headless", "disable-gpu", "window-size=1024,768");

                return(new EdgeDriver(AppDomain.CurrentDomain.BaseDirectory, options));
            }).
            UseBaseUrl("https://demo.atata.io/").
            UseCulture("en-US").
            UseAllNUnitFeatures().
            Build();
        }
Beispiel #6
0
        public void GlobalSetUp()
        {
            AtataContext.GlobalConfiguration
            .UseDriver(() =>
            {
                EdgeOptions options = new EdgeOptions
                {
                    UseChromium = true
                };

                options.AddArguments("headless", "disable-gpu", "window-size=1024,768");

                return(new EdgeDriver(options));
            })
            .UseBaseUrl("https://demo.atata.io/")
            .UseCulture("en-US")
            .UseAllNUnitFeatures();

            DriverSetup.AutoSetUp(BrowserNames.Edge);
        }
Beispiel #7
0
        public EdgeBrowser(string driver, TimeSpan timeout, params string[] arguments)
        {
            var file = base.ValidateDriver(driver);

            var options = new EdgeOptions
            {
                UseChromium = true
            };

            if (arguments != null && arguments.Length > 0)
            {
                options.AddArguments(arguments);
            }

            var service = EdgeDriverService.CreateChromiumService(file.DirectoryName, file.Name);

            service.EnableVerboseLogging    = false;
            service.HideCommandPromptWindow = true;

            this.Timeout    = timeout;
            this.Driver     = new EdgeDriver(service, options);
            this.DriverWait = new WebDriverWait(base.Driver, timeout);
        }
Beispiel #8
0
 private void SetEdgeChromiumArguments(EdgeOptions options)
 {
     options.AddArguments(BrowserStartArguments);
 }