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. |
| Selector | selector | The Selector used |
| System.Boolean | matchedAll | true - all elements matched in foundElements |
Returns
| Type | Description |
|---|---|
| System.Int32 | try the next handler in the chain based upon handler return value |
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;
}