Ejemplo n.º 1
0
        /// <summary>
        /// Starts a session with the driver
        /// </summary>
        /// <param name="desiredCapabilities">Capabilities of the browser</param>
        protected void StartSession(ICapabilities desiredCapabilities)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            // If the object passed into the RemoteWebDriver constructor is a
            // RemoteSessionSettings object, it is expected that all intermediate
            // and end nodes are compliant with the W3C WebDriver Specification,
            // and therefore will already contain all of the appropriate values
            // for establishing a session.
            RemoteSessionSettings remoteSettings = desiredCapabilities as RemoteSessionSettings;

            if (remoteSettings == null)
            {
                Dictionary <string, object> matchCapabilities = this.GetCapabilitiesDictionary(desiredCapabilities);

                List <object> firstMatchCapabilitiesList = new List <object>();
                firstMatchCapabilitiesList.Add(matchCapabilities);

                Dictionary <string, object> specCompliantCapabilitiesDictionary = new Dictionary <string, object>();
                specCompliantCapabilitiesDictionary["firstMatch"] = firstMatchCapabilitiesList;

                parameters.Add("capabilities", specCompliantCapabilitiesDictionary);
            }
            else
            {
                parameters.Add("capabilities", remoteSettings.ToDictionary());
            }

            Response response = this.Execute(DriverCommand.NewSession, parameters);

            Dictionary <string, object> rawCapabilities = response.Value as Dictionary <string, object>;

            if (rawCapabilities == null)
            {
                string errorMessage = string.Format(CultureInfo.InvariantCulture, "The new session command returned a value ('{0}') that is not a valid JSON object.", response.Value);
                throw new WebDriverException(errorMessage);
            }

            ReturnedCapabilities returnedCapabilities = new ReturnedCapabilities(rawCapabilities);

            this.capabilities = returnedCapabilities;
            this.sessionId    = new SessionId(response.SessionId);
        }
        public void GivenINavigateToThePageWithFirefox(string p0)
        {
            var caps = new OpenQA.Selenium.RemoteSessionSettings();

            caps.AddMetadataSetting("name", "Parallel Firefox Test Example");
            caps.AddMetadataSetting("build", "1.0");
            caps.AddMetadataSetting("browserName", "Firefox");
            caps.AddMetadataSetting("version", "72x64");
            caps.AddMetadataSetting("platform", "Windows 10");
            caps.AddMetadataSetting("screenResolution", "1366x768");
            caps.AddMetadataSetting("record_video", "true");
            caps.AddMetadataSetting("username", username);
            caps.AddMetadataSetting("password", authkey);


            // Start the remote webdriver
            driverFirefox = new RemoteWebDriver(new Uri("http://hub.crossbrowsertesting.com:80/wd/hub"), caps, TimeSpan.FromSeconds(180));

            // Navigate to site
            driverFirefox.Manage().Window.Maximize();
            driverFirefox.Navigate().GoToUrl(p0);
        }