Browser

Mouse and Keyboard

Methods for simulating clicks, keyboard input, drag-and-drop, and modifier key combinations.

Methods for simulating clicks, keyboard input, drag-and-drop, and modifier key combinations.

LeftClick, LeftDoubleClick, MiddleClick, and RightClick operate on the element(s) matched by the current selector. Hover moves the mouse over the element without clicking. Focus makes the element the active element - if it's editable (an input, textarea, contenteditable, or anything with a text caret) Focus performs a real click first, placing the caret and readying it for typing; non-editable elements are focused/moved-to without a click. DragAndDrop drags the matched element to a target - configure the drop coordinates with a second selector or offset. SendString types a literal text string, dispatching real key events one character at a time - its pacing is controlled by GPAL.WithTypingDelay (default 0, no delay between characters); set it greater than 0 to slow typing down on every engine (Hardware, Selenium, Puppeteer, OttoMagic) by sleeping a random duration between Math.Min(25, TypingDelay) and TypingDelay milliseconds before each character. SendKey sends a virtual key code for special keys like Enter, Tab, and Escape. PressModifierKey and ReleaseModifierKey hold modifier keys across subsequent actions. Hide sets an element's CSS display to none, removing it from the page layout without deleting it from the DOM - available both as the fluent browser.WithSelector(selector).Hide() (workflow-based, hides every matched element) and as gpalElement.Hide() (element-based, hides one already-resolved element).

TIP

StealthLeftClick uses Runtime.disable to reduce detection in environments that monitor click events. Use it when standard LeftClick triggers bot-detection checks.

Examples

GPAL Fluent: High-level fluent C# API

//SendKey accepts Windows virtual key codes (VK codes) as a byte. Common values: 0x0D = Enter, 0x09 = Tab, 0x1B = Escape, 0x41-0x5A = A-Z.

// Click a button GPAL.Browser .GoTo("https://example.com") .WithSelector("#submit") .LeftClick(); // Type text into an input GPAL.Browser .WithSelector("#search") .SendString("GPAL automation") .SendKey(0x0D); // Enter // Ctrl+A then type (select all and replace) GPAL.Browser .WithSelector("#notes") .PressModifierKey(ModifierKeys.Control) .SendKey(0x41) // A .ReleaseModifierKey(ModifierKeys.Control) .SendString("replacement text"); // Focus an input before typing (clicks to place the caret since it's editable) GPAL.Browser .WithSelector("#search") .Focus() .SendString("GPAL automation"); // Hide an element - fluent (workflow) form GPAL.Browser .WithSelector(".cookie-banner") .Hide(); // Hide an element - element-based form gPalElement.Hide();