Beispiel #1
0
        public OpenQA.Selenium.RemoteSessionSettings _choose()
        {
            //Searches through the capabilities and browsers list to find the best match according to user input

            Capability caps          = new Capability();
            browser    browserChosen = new browser();

            if (platform != "")
            {
                caps = bestOption(platform);
            }

            if (browse != "")
            {
                browserChosen = bestBrowserNoPlatform(caps.browsers, browse);
            }



            desiredCapabilities = new OpenQA.Selenium.RemoteSessionSettings();

            if (browse != "")
            {
                desiredCapabilities.AddMetadataSetting("browserName", browserChosen.browserName);
            }
            if (platform != "")
            {
                desiredCapabilities.AddMetadataSetting("platform", caps.platform);
            }
            if (width != "" && height != "")
            {
                desiredCapabilities.AddMetadataSetting("screen_resolution", width + "x" + height);
            }
            if (name != "")
            {
                desiredCapabilities.AddMetadataSetting("name", name);
            }
            if (version != "")
            {
                desiredCapabilities.AddMetadataSetting("build", version);
            }
            desiredCapabilities.AddMetadataSetting("username", username);
            desiredCapabilities.AddMetadataSetting("password", authkey);


            return(desiredCapabilities);
        }
Beispiel #2
0
        public browser bestBrowserNoPlatform(List <browser> options, string target)
        {
            //This finds and returns a perfect match when searching for a browser by api name and name


            browser bestOption = options.ElementAt(0);

            foreach (browser browserOption in options)
            {
                if (target.ToLower().Equals(browserOption.apiName.ToLower()) || target.ToLower().Equals(browserOption.name.ToLower()))
                {
                    return(browserOption);
                }
            }



            return(bestOption);
        }
Beispiel #3
0
        public void parseArray(JProperty jProperty)
        {
            //Parses an array to separate values in the json and convert to objects


            JArray jArray = (JArray)jProperty.Value;

            foreach (JObject jOBrowsers in jArray.Children <JObject>())
            {
                foreach (JProperty p in jOBrowsers.Properties())
                {
                    {
                        if (p.Value.Type == JTokenType.Integer)
                        {
                            string name = p.Name;
                            // if (p.Name != "caps")

                            string value = (string)p.Value;

                            if (jProperty.Name == "resolutions")
                            {
                                if (name == "width")
                                {
                                    tempResolution       = new resolution();
                                    tempResolution.width = value;
                                }
                                if (name == "height")
                                {
                                    tempResolution.height = value;
                                }
                            }
                        }

                        if (p.Value.Type == JTokenType.String)
                        {
                            string name = p.Name;

                            {
                                string value = (string)p.Value;

                                if (jProperty.Name == "browsers")
                                {
                                    if (name == "name")
                                    {
                                        tempBrowser      = new browser();
                                        tempBrowser.name = value;
                                    }
                                    if (name == "api_name")
                                    {
                                        tempBrowser.apiName = value;
                                    }
                                }
                                if (jProperty.Name == "resolutions")
                                {
                                    if (name == "name")
                                    {
                                        tempResolution.name = value;
                                        capabilities[capabilities.Count - 1].resolutions.Add(tempResolution);
                                    }
                                }
                            }
                        }
                        if (p.Value.Type == JTokenType.Object)
                        {
                            if (p.Name == "caps")
                            {
                                parseObject(p);
                            }
                        }
                        if (p.Value.Type == JTokenType.Array)
                        {
                            if (p.Name == "browsers")
                            {
                                parseArray(p);
                            }
                            if (p.Name == "resolutions")
                            {
                                parseArray(p);
                            }
                        }
                    }
                }
            }
        }