Пример #1
0
        public async Task StartAsync()
        {
            await Server.StartAsync();

            ChromeOptions options = new ChromeOptions();
            var           isDebug = !Server.PayTester.InContainer;

            if (!isDebug)
            {
                options.AddArguments("headless");              // Comment to view browser
                options.AddArguments("window-size=1200x1000"); // Comment to view browser
            }
            options.AddArgument("shm-size=2g");
            if (Server.PayTester.InContainer)
            {
                options.AddArgument("no-sandbox");
            }
            Driver = new ChromeDriver(Server.PayTester.InContainer ? "/usr/bin" : Directory.GetCurrentDirectory(), options);
            if (isDebug)
            {
                //when running locally, depending on your resolution, the website may go into mobile responsive mode and screw with navigation of tests
                Driver.Manage().Window.Maximize();
            }
            Logs.Tester.LogInformation("Selenium: Using chrome driver");
            Logs.Tester.LogInformation("Selenium: Browsing to " + Server.PayTester.ServerUri);
            Logs.Tester.LogInformation($"Selenium: Resolution {Driver.Manage().Window.Size}");
            Driver.Manage().Timeouts().ImplicitWait = ImplicitWait;
            GoToRegister();
            Driver.AssertNoError();
        }
Пример #2
0
        public async Task StartAsync()
        {
            await Server.StartAsync();

            ChromeOptions options = new ChromeOptions();

            if (Server.PayTester.InContainer)
            {
                // this must be first option https://stackoverflow.com/questions/53073411/selenium-webdriverexceptionchrome-failed-to-start-crashed-as-google-chrome-is#comment102570662_53073789
                options.AddArgument("no-sandbox");
            }

            var isDebug = !Server.PayTester.InContainer;

            if (!isDebug)
            {
                options.AddArguments("headless");              // Comment to view browser
                options.AddArguments("window-size=1200x1000"); // Comment to view browser
            }
            options.AddArgument("shm-size=2g");
            Driver = new ChromeDriver(Server.PayTester.InContainer ? "/usr/bin" : Directory.GetCurrentDirectory(), options);
            if (isDebug)
            {
                //when running locally, depending on your resolution, the website may go into mobile responsive mode and screw with navigation of tests
                Driver.Manage().Window.Maximize();
            }
            Logs.Tester.LogInformation("Selenium: Using chrome driver");
            Logs.Tester.LogInformation("Selenium: Browsing to " + Server.PayTester.ServerUri);
            Logs.Tester.LogInformation($"Selenium: Resolution {Driver.Manage().Window.Size}");
            Driver.Manage().Timeouts().ImplicitWait = ImplicitWait;
            GoToRegister();
            Driver.AssertNoError();
        }
Пример #3
0
        public async Task StartAsync()
        {
            await Server.StartAsync();

            var windowSize = (Width : 1200, Height : 1000);
            var builder    = new ConfigurationBuilder();

            builder.AddUserSecrets("AB0AC1DD-9D26-485B-9416-56A33F268117");
            var config = builder.Build();

            // Run `dotnet user-secrets set RunSeleniumInBrowser true` to run tests in browser
            var runInBrowser = config["RunSeleniumInBrowser"] == "true";
            // Reset this using `dotnet user-secrets remove RunSeleniumInBrowser`

            var chromeDriverPath = config["ChromeDriverDirectory"] ?? (Server.PayTester.InContainer ? "/usr/bin" : Directory.GetCurrentDirectory());

            var options = new ChromeOptions();

            if (Server.PayTester.InContainer)
            {
                // this must be first option https://stackoverflow.com/questions/53073411/selenium-webdriverexceptionchrome-failed-to-start-crashed-as-google-chrome-is#comment102570662_53073789
                options.AddArgument("no-sandbox");
            }
            if (!runInBrowser)
            {
                options.AddArguments("headless");
            }
            options.AddArguments($"window-size={windowSize.Width}x{windowSize.Height}");
            options.AddArgument("shm-size=2g");

            var cds = ChromeDriverService.CreateDefaultService(chromeDriverPath);

            cds.Port     = Utils.FreeTcpPort();
            cds.HostName = "127.0.0.1";
            cds.Start();
            Driver = new ChromeDriver(cds, options,
                                      // A bit less than test timeout
                                      TimeSpan.FromSeconds(50));

            if (runInBrowser)
            {
                // ensure maximized window size
                // otherwise TESTS WILL FAIL because of different hierarchy in navigation menu
                Driver.Manage().Window.Maximize();
            }

            Logs.Tester.LogInformation($"Selenium: Using {Driver.GetType()}");
            Logs.Tester.LogInformation($"Selenium: Browsing to {Server.PayTester.ServerUri}");
            Logs.Tester.LogInformation($"Selenium: Resolution {Driver.Manage().Window.Size}");
            GoToRegister();
            Driver.AssertNoError();
        }
Пример #4
0
        public async Task StartAsync()
        {
            await Server.StartAsync();

            var windowSize = (Width : 1200, Height : 1000);
            var builder    = new ConfigurationBuilder();

            builder.AddUserSecrets("AB0AC1DD-9D26-485B-9416-56A33F268117");
            var config = builder.Build();

            // Run `dotnet user-secrets set RunSeleniumInBrowser true` to run tests in browser
            var runInBrowser = config["RunSeleniumInBrowser"] == "true";
            // Reset this using `dotnet user-secrets remove RunSeleniumInBrowser`


            var chromeDriverPath = config["ChromeDriverDirectory"] ??
                                   (Server.PayTester.InContainer ? "/usr/bin" : Directory.GetCurrentDirectory());

            var options = new ChromeOptions();

            if (Server.PayTester.InContainer)
            {
                // this must be first option https://stackoverflow.com/questions/53073411/selenium-webdriverexceptionchrome-failed-to-start-crashed-as-google-chrome-is#comment102570662_53073789
                options.AddArgument("no-sandbox");
            }
            if (!runInBrowser)
            {
                options.AddArguments("headless");
            }
            options.AddArguments($"window-size={windowSize.Width}x{windowSize.Height}");
            options.AddArgument("shm-size=2g");
            Driver = new ChromeDriver(chromeDriverPath, options);

            if (runInBrowser)
            {
                // ensure maximized window size
                Driver.Manage().Window.Maximize();
            }

            Logs.Tester.LogInformation($"Selenium: Using {Driver.GetType()}");
            Logs.Tester.LogInformation($"Selenium: Browsing to {Server.PayTester.ServerUri}");
            Logs.Tester.LogInformation($"Selenium: Resolution {Driver.Manage().Window.Size}");
            Driver.Manage().Timeouts().ImplicitWait = ImplicitWait;
            GoToRegister();
            Driver.AssertNoError();
        }
Пример #5
0
        public void Start()
        {
            Server.Start();
            ChromeOptions options = new ChromeOptions();

            options.AddArguments("headless");             // Comment to view browser
            options.AddArguments("window-size=1200x600"); // Comment to view browser
            options.AddArgument("shm-size=2g");
            if (Server.PayTester.InContainer)
            {
                options.AddArgument("no-sandbox");
            }
            Driver = new ChromeDriver(Server.PayTester.InContainer ? "/usr/bin" : Directory.GetCurrentDirectory(), options);
            Logs.Tester.LogInformation("Selenium: Using chrome driver");
            Logs.Tester.LogInformation("Selenium: Browsing to " + Server.PayTester.ServerUri);
            Logs.Tester.LogInformation($"Selenium: Resolution {Driver.Manage().Window.Size}");
            Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            Driver.Navigate().GoToUrl(Server.PayTester.ServerUri);
            Driver.AssertNoError();
        }