Esempio n. 1
0
        /// <summary>
        /// Find a specified element by selector
        /// </summary>
        /// <param name="selector">selector to use to locate element</param>
        /// <returns>element or throws an exception</returns>
        public virtual IWebElement FindElement(string selector)
        {
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            switch (_fixture.Configuration.Selector)
            {
            case SelectorAlgorithm.JQuery:
                return(_fixture.Driver.FindElement(Using.JQuery(selector)));

            case SelectorAlgorithm.CSS:
                return(_fixture.Driver.FindElement(By.CssSelector(selector)));

            case SelectorAlgorithm.XPath:
                return(_fixture.Driver.FindElement(By.XPath(selector)));

            case SelectorAlgorithm.Auto:
                return(_fixture.Driver.FindElement(Using.Auto(selector)));

            default:
                throw new Exception("Unknown SelectorAlgorithm " + _fixture.Configuration.Selector);
            }
        }
Esempio n. 2
0
        protected virtual void SetDictionaryValuesIntoForm(IWebElement webElement, IEnumerable <KeyValuePair <string, object> > keyValuePairs)
        {
            foreach (KeyValuePair <string, object> keyValuePair in keyValuePairs)
            {
                var elements = webElement.FindElements(Using.Auto(keyValuePair.Key));

                if (elements.Count == 0)
                {
                    throw new Exception("Could not locate any element using: " + keyValuePair.Key);
                }

                foreach (IWebElement element in elements)
                {
                    FillElementWithValues(element, keyValuePair.Value);
                }
            }
        }