Exemplo n.º 1
0
        public static By AttributeValue(string attributeName, string attributeValue)
        {
            Via byAttribute = new Via();

            byAttribute.FindElementMethod  = (ISearchContext context) => { return(FindElementByAttributeValue(context, attributeName, attributeValue)); };
            byAttribute.FindElementsMethod = (ISearchContext context) => { return(FindElementsByAttributeValue(context, attributeName, attributeValue)); };
            return(byAttribute);
        }
Exemplo n.º 2
0
        public static By JavaScript(string script)
        {
            Via byJavaScript = new Via();

            byJavaScript.FindElementMethod  = (ISearchContext context) => { return(FindElementByJavaScript(context, script)); };
            byJavaScript.FindElementsMethod = (ISearchContext context) => { return(FindElementsByJavaScript(context, script)); };
            return(byJavaScript);
        }
Exemplo n.º 3
0
        public void LocatorsOfAllKinds(IWebDriver driver)
        {
            // This locator will never work!
            By illegal = By.CssSelector("a:contains('hello')");

            // This is the proper way to find by element text.
            By textLocator = By.XPath("//a[contains(text(), 'hello')]");

            // Can even use custom locators!
            By findByAttribute  = Via.AttributeValue("data-value", "myvalue");
            By findByJavaScript = Via.JavaScript("return document.getElementById('foo');");
        }