Exemplo n.º 1
0
        static FlowStep CollectionByXPath(IFindsByXPath parent, string xpath) => (Context context) =>
        {
            ReadOnlyCollection <IWebElement> result = null;

            if (!TryUntilSuccess(() =>
            {
                result = parent.FindElementsByXPath(xpath);

                return(result != null && result.Count > 0); // Satisfied only by non-empty collection
            }))
            {
                return(context.CreateProblem($"{nameof(CollectionByXPath)}: '{xpath}' failed"));
            }

            return(context.NextContext(result));
        };
Exemplo n.º 2
0
        static FlowStep ElementByXPath(IFindsByXPath parent, string xpath, int index = 0) => (Context context) =>
        {
            RemoteWebElement child = null;

            if (!TryUntilSuccess(() =>
            {
                child = index == 0 ?
                        parent.FindElementByXPath(xpath) as RemoteWebElement
                    : parent.FindElementsByXPath(xpath)[index] as RemoteWebElement;

                return(child != null);
            }))
            {
                return(context.CreateProblem($"{nameof(ElementByXPath)}: '{xpath}' failed"));
            }

            return(context.NextContext(child));
        };
Exemplo n.º 3
0
 static bool ExistsByXPath(IFindsByXPath parent, string xpath) => ElementExists(parent.FindElementByXPath, xpath);