Show / Hide Table of Contents

Delegate Browser.CallIfDelegate

Delegate callback for the CallIfFound/CallIfNotFound EventHandlers which will be invoked when a selector is found/not found
CallIf handlers may be defined at two levels: At each selector or for a Unit of Work (UOW) [will be invoked for each Selector in the UOW]
A UOW is defined as all Selectors between actions (first action is Goto)
More than one callback handler can be defined and subsequent handlers will only be invoked based upon return code values

Namespace: GenerallyPositive.Browser
Assembly: GPAL.dll
Syntax
public delegate int CallIfDelegate(Browser browser, List<GPALElement> foundElements, List<GPALElement> matchedElements, Selector selector, bool matchedAll);
Parameters
Type Name Description
Browser browser

The current browser running

System.Collections.Generic.List<GPALElement> foundElements

All found elements

System.Collections.Generic.List<GPALElement> matchedElements

All matched elements.
If a 'Match' criteria is set on a Selector, otherwise all found

Selector selector

The Selector used

System.Boolean matchedAll

true - all elements matched in foundElements
false - matchedElements out of foundElements

Returns
Type Description
System.Int32

try the next handler in the chain based upon handler return value
0 = not handled, bubble to next handler
1 = handled and continue with the program
-1 = terminate program

Examples
public static int FoundAllCookies(Browser browser, List<GPALElement> foundElements, List<GPALElement> matchedElements, Selector selector, bool matchedAll)
{
    int retVal = 0;
    foreach (GPALElement webElement in foundElements)
    {
        if (true == webElement.Text.ToLower().Contains("accept"))   // "Accept all cookies"
        {
            webElement.Click();
            selector.Browser.RemoveCallIfHandlerEverywhere(FoundAllCookies);
            selector.Remove();
            retVal = 1;
        }
    }
    return retVal;
}
In This Article
Back to top Generated by DocFX