public void TestStartsAndStopsLocalSession()
        {
            Local local = new Local();

            void startWithOptions()
            {
                local.start(options);
            }

            Assert.DoesNotThrow(new TestDelegate(startWithOptions));
            Process[] binaryInstances = Process.GetProcessesByName("BrowserStackLocal");
            Assert.AreNotEqual(binaryInstances.Length, 0);

            IWebDriver  driver;
            EdgeOptions capability = new EdgeOptions();

            capability.AddAdditionalCapability("browserstack.user", username);
            capability.AddAdditionalCapability("browserstack.key", accesskey);
            capability.AddAdditionalCapability("browserstack.local", true);
            capability.AddAdditionalCapability("build", "C Sharp binding Integration Test");

            driver = new RemoteWebDriver(
                new Uri("http://hub.browserstack.com/wd/hub/"), capability
                );
            driver.Navigate().GoToUrl("http://bs-local.com:45691/check");
            String status = driver.FindElement(By.TagName("body")).Text;

            Assert.AreEqual(status, "Up and running");

            driver.Quit();
            local.stop();

            binaryInstances = Process.GetProcessesByName("BrowserStackLocal");
            Assert.AreEqual(binaryInstances.Length, 0);
        }
Exemple #2
0
    public static IWebDriver OpenBrowser(string url)
    {
        IWebDriver driver;

        if (Constants.BrowserName == "Chrome")
        {
            ChromeOptions option = new ChromeOptions();
            option.AddArgument("--start-maximized");
            driver = new ChromeDriver(option);
        }
        else if (Constants.BrowserName == "Firefox")
        {
            driver = new FirefoxDriver();
        }
        else
        {
            string serverPath = "Microsoft Web Driver";
            if (System.Environment.Is64BitOperatingSystem)
            {
                serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), serverPath);
            }
            else
            {
                serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles%"), serverPath);
            }

            EdgeOptions options = new EdgeOptions();
            driver = new EdgeDriver(serverPath, options);
        }
        driver.Navigate().GoToUrl(url);
        WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

        wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
        return(driver);
    }
Exemple #3
0
        private void imageViewer1_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e)
        {
            if (imageViewer1.Roi.Count > 0 && imageViewer1.Roi[0].Type == ContourType.Line)
            {
                // Fill in the edge options structure from the controls on the form.
                EdgeOptions options = new EdgeOptions();
                options.ColumnProcessingMode = (ColumnProcessingMode)Enum.Parse(typeof(ColumnProcessingMode), (string)smoothing.SelectedItem);
                options.InterpolationType    = (InterpolationMethod)Enum.Parse(typeof(InterpolationMethod), (string)interpolationMethod.SelectedItem);
                options.KernelSize           = (uint)kernelSize.Value;
                options.MinimumThreshold     = (uint)minimumThreshold.Value;
                options.Polarity             = (EdgePolaritySearchMode)Enum.Parse(typeof(EdgePolaritySearchMode), (string)polarity.SelectedItem);
                options.Width = (uint)width.Value;

                // Run the edge detection
                EdgeReport report = Algorithms.EdgeTool(imageViewer1.Image, imageViewer1.Roi, (EdgeProcess)Enum.Parse(typeof(EdgeProcess), (string)process.SelectedItem),
                                                        options);

                // Overlay the edge positions
                imageViewer1.Image.Overlays.Default.Clear();
                foreach (EdgeInfo edge in report.Edges)
                {
                    imageViewer1.Image.Overlays.Default.AddOval(new OvalContour(edge.Position.X - 2, edge.Position.Y - 2, 5, 5), Rgb32Value.RedColor, DrawingMode.PaintValue);
                }

                // Graph the line profile and the gradient of the line.
                LineProfileReport lineProfile = Algorithms.LineProfile(imageViewer1.Image, imageViewer1.Roi);
                double[]          profileData = new double[lineProfile.ProfileData.Count];
                lineProfile.ProfileData.CopyTo(profileData, 0);

                double[] gradientData = new double[report.GradientInfo.Count];
                report.GradientInfo.CopyTo(gradientData, 0);
                edgeDetectionGraph1.PlotData(profileData, gradientData);
            }
        }
        public static Task <IWebDriver> GetEdgeDriverAsync()
        {
            var options = new EdgeOptions()
            {
                PageLoadStrategy        = PageLoadStrategy.Eager,
                UnhandledPromptBehavior = UnhandledPromptBehavior.Accept,
                UseInPrivateBrowsing    = true
            };

            var pathsToCheck = new[]
            {
                Path.Combine("C:", "Windows", "SysWOW64"),
                Path.Combine(
                    Environment.CurrentDirectory,
                    "Drivers")
            };

            var driverFileName = "MicrosoftWebDriver.exe";
            var pathToUse      = pathsToCheck
                                 .First(x => File.Exists(
                                            Path.Combine(x, driverFileName)));

            var service = EdgeDriverService.CreateDefaultService(
                pathToUse,
                driverFileName,
                52296);

            var driver = new EdgeDriver(service, options);

            return(Task.FromResult <IWebDriver>(driver));
        }
Exemple #5
0
        static IWebDriver GetDriver(Action <DriverOptions> driverOptions)
        {
            var options = new EdgeOptions();

            driverOptions?.Invoke(options);
            return(new SeleniumEdgeDriver(AppDomain.CurrentDomain.BaseDirectory, options));
        }
        private static ICapabilities ReturnBrowserOptions(string platformName,
                                                          string browserName,
                                                          string browserVersion)
        {
            DriverOptions browserOptions;

            switch (browserName)
            {
            case "chrome":
                browserOptions = new ChromeOptions();
                break;

            case "edge":
                browserOptions = new EdgeOptions();
                break;

            case "firefox":
                browserOptions = new FirefoxOptions();
                break;

            case "safari":
                browserOptions = new SafariOptions();
                break;

            default:
                throw new Exception($"Browser {browserName} not supported!");
            }

            browserOptions.PlatformName   = platformName;
            browserOptions.BrowserVersion = browserVersion;
            return(browserOptions.ToCapabilities());
        }
Exemple #7
0
        public void TestEdge()
        {
            IWebDriver driver = null;

            try
            {
                EdgeOptions options = new EdgeOptions();
                options.PageLoadStrategy = EdgePageLoadStrategy.Default;

                driver     = new EdgeDriver();
                driver.Url = "http://www.softpost.org";
                driver.Manage().Window.Maximize();
                driver.Navigate();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception ....*********" + e.ToString());
            }

            finally
            {
                Thread.Sleep(2000);
                driver.Close();
                driver.Quit();
            }
        }
        public void getBrowser()
        {
            string browser = getConfigData("Browser");

            switch (browser.ToLower())
            {
            case "chrome":
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.Proxy = null;
                driver = new ChromeDriver(driverPath, chromeOptions);
                break;

            case "firefox":
                FirefoxOptions firefoxOptions = new FirefoxOptions();
                firefoxOptions.Proxy = null;
                driver = new FirefoxDriver(driverPath, firefoxOptions);
                break;

            case "ie":
                InternetExplorerOptions ieOptions = new InternetExplorerOptions();
                ieOptions.Proxy = null;
                driver          = new InternetExplorerDriver(driverPath, ieOptions);
                break;

            case "edge":
                EdgeOptions edgeOptions = new EdgeOptions();
                edgeOptions.Proxy = null;
                driver            = new EdgeDriver(driverPath, edgeOptions);
                break;
            }
        }
        public void Start()
        {
            EdgeOptions options = new EdgeOptions();

            _driver = new EdgeDriver(options);
            _wait   = new WebDriverWait(_driver, TimeSpan.FromSeconds(100));
        }
    public void TestInEdge()
    {
        string serverPath = "Microsoft Web Driver";

        if (System.Environment.Is64BitOperatingSystem)
        {
            serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), serverPath);
        }
        else
        {
            serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles%"), serverPath);
        }

        // location for MicrosoftWebDriver.exe
        EdgeOptions options = new EdgeOptions();

        options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
        IWebDriver driver = new EdgeDriver(serverPath, options);

        System.Diagnostics.Debug.Write("Start... ");

        driver.Navigate().GoToUrl("http://travel.agileway.net");
        driver.FindElement(By.Name("username")).SendKeys("agileway");
        IWebElement passwordElem = driver.FindElement(By.Name("password"));

        passwordElem.SendKeys("testwise");
        passwordElem.Submit(); // not implemented
        System.Threading.Thread.Sleep(1000);
        driver.Quit();
    }
        private IWebDriver GetBrowserDriver(string environment, string url)
        {
            switch (environment)
            {
            case "chrome": {
                return(new ChromeDriver());
            }

            case "ie": {
                var ieOptions = new InternetExplorerOptions();
                ieOptions.InitialBrowserUrl = url;
                return(new InternetExplorerDriver(ieOptions));
            }

            case "firefox": {
                return(new FirefoxDriver());
            }

            case "opera": {
                return(new OperaDriver());
            }

            case "edge": {
                var options = new EdgeOptions();
                options.PageLoadStrategy = EdgePageLoadStrategy.Eager;

                return(new EdgeDriver(@"C:\Users\mashhood.m\source\repos\SpecFlowTestApp\SpecFlowTestApp.AcceptanceTests\bin\Debug\"));
            }
            }
            return(null);
        }
        protected override IWebDriver DoBuildAndGetWebDriver(BrowserConfig browserConfig)
        {
            EdgeOptions edgeOptions = new EdgeOptions();
            IWebDriver  webDriver   = new EdgeDriver(browserConfig.WebDriverPath);

            return(webDriver);
        }
Exemple #13
0
        public IWebDriver GetLocalDriver()
        {
            var options    = new EdgeOptions();
            var edgeDriver = new EdgeDriver(WebDriverConstants.LocalPath.Driver, options);

            return(edgeDriver);
        }
Exemple #14
0
        public dynamic Setcapabilites(WebBrowserConfiguration webBrowserConfiguration)
        {
            EdgeOptions option = new EdgeOptions();

            option.PageLoadStrategy = PageLoadStrategy.Eager;
            return(option);
        }
        public DriverOptions GetOptions()
        {
            var options = new EdgeOptions();

            options.PageLoadStrategy = PageLoadStrategy.Eager;
            return(options);
        }
Exemple #16
0
        public static IWebDriver GetDriver()
        {
            if (driver == null)
            {
                switch (TestContext.Parameters.Get("browser"))
                {
                case "Edge":
                    new DriverManager().SetUpDriver(new EdgeConfig());
                    EdgeOptions edgeOptions = new EdgeOptions();
                    driver = new EdgeDriver();
                    break;

                default:
                    new DriverManager().SetUpDriver(new ChromeConfig());
                    ChromeOptions chromeOptions = new ChromeOptions();
                    chromeOptions.AddArguments("--whitelist-ip *");
                    chromeOptions.AddArguments("--proxy-server='direct://'");
                    chromeOptions.AddArguments("--proxy-bypass-list=*");
                    driver = new ChromeDriver(chromeOptions);
                    break;
                }
                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);
                driver.Manage().Timeouts().PageLoad     = TimeSpan.FromSeconds(120);
                driver.Manage().Window.Maximize();
            }
            return(driver);
        }
Exemple #17
0
        public void W3CEdge()
        {
            //TODO please supply your Sauce Labs user name in an environment variable
            var sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME", EnvironmentVariableTarget.User);
            //TODO please supply your own Sauce Labs access Key in an environment variable
            var sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY", EnvironmentVariableTarget.User);

            var options = new EdgeOptions()
            {
                BrowserVersion = "latest",
                PlatformName   = "Windows 10"
            };

            var sauceOptions = new Dictionary <string, object>
            {
                ["username"]  = sauceUserName,
                ["accessKey"] = sauceAccessKey,
                ["name"]      = TestContext.CurrentContext.Test.Name
            };

            options.AddAdditionalCapability("sauce:options", sauceOptions);

            _driver = new RemoteWebDriver(new Uri("https://ondemand.saucelabs.com/wd/hub"), options.ToCapabilities(),
                                          TimeSpan.FromSeconds(600));
            _driver.Navigate().GoToUrl("https://www.google.com");
            Assert.Pass();
        }
        public void GivenIAmUsing(string browser)
        {
            if (browser.Equals("chrome"))
            {
                var chromeOptions = new ChromeOptions();
                chromeOptions.AddArgument("start-maximized");
                chromeOptions.AddArgument("--disable-extensions");
                chromeOptions.AddArguments("--headless");
                webDriver = new ChromeDriver(chromeOptions);
            }

            else if (browser.Equals("firefox"))
            {
                webDriver = new FirefoxDriver();
            }
            else if (browser.Equals("edge"))
            {
                EdgeOptions edgeOptions = new EdgeOptions();
                edgeOptions.UseChromium = true;
                webDriver = new EdgeDriver(edgeOptions);
            }
            else
            {
                throw new Exception("Browser not Identified");
            }
            webDriver.Navigate().GoToUrl("https://viewpoint.glasslewis.com/WD/?siteId=DemoClient");
            webDriver.Manage().Window.Maximize();
            Thread.Sleep(5000);
            homepage = new Homepage(webDriver, wait);
        }
Exemple #19
0
        /// <summary>
        /// The create local driver.
        /// </summary>
        /// <param name="capabilities">
        /// The capabilities.
        /// </param>
        /// <returns>
        /// The <see cref="IWebDriver"/>.
        /// </returns>
        /// <exception cref="Exception">
        /// </exception>
        private static IWebDriver CreateLocalDriver(ICapabilities capabilities)
        {
            // Implementation is incomplete: the capabilities are not converted to the options for all browsers
            string browserType = (string)capabilities.GetCapability("BrowserName");

            if (browserType == new FirefoxOptions().BrowserName)
            {
                var options = new FirefoxOptions();
                return(new FirefoxDriver(options));
            }

            if (browserType == new InternetExplorerOptions().BrowserName)
            {
                return(new InternetExplorerDriver());
            }

            if (browserType == new ChromeOptions().BrowserName)
            {
                return(new ChromeDriver());
            }

            if (browserType == new SafariOptions().BrowserName)
            {
                return(new SafariDriver());
            }

            if (browserType == new EdgeOptions().BrowserName)
            {
                var options = new EdgeOptions();
                options.AddAdditionalCapability("timeZone", "Europe/London");
                return(new EdgeDriver(options));
            }

            throw new Exception("Unrecognized browser type: " + browserType);
        }
        public void EdgeSession()
        {
            var options = new EdgeOptions();
            var driver  = new EdgeDriver(options);

            driver.Quit();
        }
        public static RemoteWebDriver GetBrowserRemote(RemoteWebDriver driver, string browser, string uri)
        {
            switch (browser)
            {
            case "Firefox":
                FirefoxOptions firefoxoptions = new FirefoxOptions();
                driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), firefoxoptions);
                driver.Navigate().GoToUrl("https://buscacepinter.correios.com.br/app/endereco/index.php");
                driver.Manage().Window.Maximize();
                break;

            case "Edge":
                EdgeOptions edgeoptions = new EdgeOptions();
                driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), edgeoptions);
                driver.Navigate().GoToUrl("https://buscacepinter.correios.com.br/app/endereco/index.php");
                driver.Manage().Window.Maximize();
                break;

            default:
                ChromeOptions chromeoptions = new ChromeOptions();
                driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), chromeoptions);
                driver.Navigate().GoToUrl("https://buscacepinter.correios.com.br/app/endereco/index.php");
                driver.Manage().Window.Maximize();
                break;
            }
            return(driver);
        }
Exemple #22
0
        public static EdgeOptions EDGEOptions()
        {
            EdgeOptions options = new EdgeOptions();

            options.PageLoadStrategy = PageLoadStrategy.Normal;
            return(options);
        }
Exemple #23
0
        public void InitializeDriver()
        {
            EdgeOptions options = new EdgeOptions();

            options.AddAdditionalCapability("InPrivate", true);
            this.edgeDriver = new EdgeDriver(this.GetExecutingDirectory(), options);
        }
Exemple #24
0
        public void TestWebViewOptions()
        {
            var options = new EdgeOptions();

            options.UseWebView = true;
            Assert.AreEqual("webview2", options.BrowserName);
        }
Exemple #25
0
        private static EdgeOptions GetEdgeOptions()
        {
            var options = new EdgeOptions();

            options.UseChromium = true;
            return(options);
        }
Exemple #26
0
        public static EdgeOptions GetEdgeOptions(PlatformType platformType = PlatformType.Any)
        {
            EdgeOptions options = new EdgeOptions();

            SetPlatform(options, platformType);
            return(options);
        }
Exemple #27
0
        public static RemoteWebDriver OpenBrowser(BrowserType browserType)
        {
            {
                switch (browserType)
                {
                case BrowserType.Chrome:
                    ChromeOptions options = new ChromeOptions();
                    options.AddArgument("--start-maximized");
                    return(new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromMinutes(2)));

                case BrowserType.FireFox:
                    FirefoxOptions firefoxOptions = new FirefoxOptions();
                    firefoxOptions.SetPreference("capability.policy.default.Window.frameElement.get", "allAccess");
                    return(new FirefoxDriver(firefoxOptions));

                case BrowserType.Edge:
                    EdgeOptions edgeOptions       = new EdgeOptions();
                    string      edgeWebDriverPath = Path.Combine(Directory.GetCurrentDirectory(), "MicrosoftWebDriver.exe");
                    return(new EdgeDriver(Directory.GetCurrentDirectory()));

                default:
                    return(null);
                }
            }
        }
Exemple #28
0
        /// <inheritdoc />
        public override DriverOptions GetOptions()
        {
            var options = new EdgeOptions();

            options.AddAdditionalCapability(CapabilityType.Proxy, DriverProvider.Proxy);
            return(options);
        }
Exemple #29
0
        public static IWebDriver GetDriver(string browser)
        {
            browser = Environment.GetEnvironmentVariable("BROWSER");

            FirefoxOptions options = new FirefoxOptions();

            options.BrowserExecutableLocation = ("C:\\Automation\\Automation\\firefox.exe");
            EdgeOptions Eoptions = new EdgeOptions();

            switch (browser)
            {
            case "chrome":
            case "Chrome":
                return(new ChromeDriver());

            case "ie":
            case "IE":
                return(new InternetExplorerDriver());

            case "edge":
            case "Edge":
                return(new EdgeDriver("C:\\Windows\\System32\\", Eoptions));

            default:
                return(new FirefoxDriver(options));
            }
        }
Exemple #30
0
        private void OpenBrowser(string browserType)
        {
            switch (browserType)
            {
            case "IE":
                var IEcapabilities = new InternetExplorerOptions();
                IEcapabilities.IgnoreZoomLevel = true;
                _parallelConfig.Driver         = new InternetExplorerDriver(Settings.IEDriver, IEcapabilities, TimeSpan.FromSeconds(180));
                _parallelConfig.BrowserName    = IEcapabilities.BrowserName;
                break;

            case "Firefox":
                var FFcapabilities = new FirefoxOptions();
                FFcapabilities.AcceptInsecureCertificates = true;
                _parallelConfig.Driver      = new FirefoxDriver(Settings.FireFoxDriver, FFcapabilities, TimeSpan.FromSeconds(180));
                _parallelConfig.BrowserName = FFcapabilities.BrowserName;
                break;

            case "Chrome":
                var CHcapabilities = new ChromeOptions();
                CHcapabilities.AddArgument("no-sandbox");
                _parallelConfig.Driver      = new ChromeDriver(Settings.ChromeDriver, CHcapabilities, TimeSpan.FromSeconds(180));
                _parallelConfig.BrowserName = CHcapabilities.BrowserName;
                break;

            case "Edge":
                var Edgecapabilities = new EdgeOptions();
                _parallelConfig.Driver      = new EdgeDriver(Settings.EdgeDriver, Edgecapabilities, TimeSpan.FromSeconds(180));
                _parallelConfig.BrowserName = Edgecapabilities.BrowserName;
                break;
            }
        }
Exemple #31
0
        public void WriteStartEdge(string id0, string id1, EdgeOptions options)
        {
            if (id0 == null)
            {
                throw new System.ArgumentNullException("id0");
            }
            if (id1 == null)
            {
                throw new System.ArgumentNullException("id1");
            }
            this.checkstate(WriterState.Graph);
            this.state = WriterState.Edge;

            this.write(id0);
            this.write("->");
            this.write(id1);
            if (options != null)
            {
                this.write(" [ ");

                if (options.Label != null)
                {
                    this.WriteNodeOption("label", options.Label);
                }
                if (options.LabelFontName != null)
                {
                    this.WriteNodeOption("fontname", options.LabelFontName);
                }

                if (options.Weight.HasValue)
                {
                    this.WriteNodeOption("weight", options.Weight.Value);
                }

                if (options.LabelFontColor != null)
                {
                    this.WriteNodeOption("fontcolor", options.LabelFontColor.Value.ToWebColorString());
                }

                if (options.LabelFontSize.HasValue)
                {
                    this.WriteNodeOption("fontsize", options.LabelFontSize.Value);
                }

                if (options.Shape != null)
                {
                    this.WriteNodeOption("shape", options.Shape.Value.ToString().ToLower());
                }

                if (options.Style != null)
                {
                    this.WriteNodeOption("style", options.Style.Value.ToString().ToLower());
                }

                if (options.Color != null)
                {
                    this.WriteNodeOption("color", options.Color.Value.ToWebColorString());
                }

                if (options.URL != null)
                {
                    this.WriteNodeOption("url", options.URL);
                }

                if (options.ToolTip != null)
                {
                    this.WriteNodeOption("tooltip", options.ToolTip);
                }

                if (options.Z != null)
                {
                    this.WriteNodeOption("z", options.Z.Value);
                }

                this.write(" ]");
            }

            this.writeline("");
        }