Core Concepts

ElementAssistant: Non-Standard Element Actions in Callbacks

GPALElement.Click() handles most callback interactions. ElementAssistant is for the cases where it can't. Switching to JavaScript or hardware interaction when Selenium clicks are intercepted, downloading or uploading via a found element, or filling text into an input element your selector already located.

When Click() Is Not Enough

GPALElement has a .Click() method -- it is the right call for most callback actions. ElementAssistant is for the cases where Selenium's click is intercepted by an overlay or popup div, or where the action needed is not just a click -- downloading a file, uploading, or filling text into an input. GPAL.ElementAssistant(uow.CurrentSelector) picks up the selector's browser reference and interaction settings and adds a .WithJavaScript or .WithHardware override and actions not available on GPALElement directly.

.CallIfFound((browser, uow, elements) => {

// Selenium click intercepted by an overlay - switch to JavaScript

GPAL.ElementAssistant(uow.CurrentSelector)

.WithJavaScript

.WithElement(elements[0])

.LeftClick();

return CallIfStatus.Handled;

})

TIP

Outside a callback, use the normal GPAL.Browser or GPAL.Selector fluent chain. It handles element lookup for you. ElementAssistant is for handlers where you already hold the GPALElement objects.

Download and Upload Actions

LeftClickAndDownload and LeftClickAndUpload are only available on ElementAssistant. There is no equivalent on GPALElement directly. Pass the element and the target GPALFile to LeftClickAndDownload to click a link and save the download, or to LeftClickAndUpload to click a file input and supply the file to upload.

public static CallIfStatus DownloadResult(IBrowser browser, UnitOfWork uow, List<GPALElement> elements)

{

ElementAssistant ea = GPAL.ElementAssistant(uow.CurrentSelector).ToGPALObject();

ea.LeftClickAndDownload(elements[0], GPAL.FileFor(@"C:Downloads esult.pdf"));

return CallIfStatus.Handled;

}

Filling Text Into a Found Input

FillInFrom, InsertFrom, and AppendFrom let you write text into an input element your selector already found. Useful when the input was located as part of a broader selector match and you want to act on the specific element in hand rather than running a new search.

.CallIfFound((browser, uow, elements) => {

GPAL.ElementAssistant(uow.CurrentSelector)

.WithElement(elements[0])

.FillInFrom("search term");

return CallIfStatus.Handled;

})