GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GenerallyPositive.Browser.PuppeteerCommunicator Class Reference

Classes

class  CastDevice
class  Node

Public Member Functions

List< GPALCallGetCapturedCalls ()
 Everything recorded so far, oldest first. A copy, so reading it is never reading what the browser is still writing. List<GPALCall> calls = browser.PuppeteerCommunicator.GetCapturedCalls();.
void ClearCapturedCalls ()
 Forgets everything recorded so far. Recording carries on.
async Task< dynamic > SendCommand< TParameters > (DevToolsMethods method, TParameters parameters, string sessionId, int retries=3, bool doNotGetSemaphore=false, int timeoutSeconds=0)
async Task< string > EnableFetchScriptInjection (string scriptToInject, string sessionId=null)
 Registers a JavaScript snippet to be evaluated automatically on every new document load for the given session, using Page.addScriptToEvaluateOnNewDocument. When Puppeteer is not in use, the equivalent Selenium Chromium CDP command is issued instead via the underlying OpenQA.Selenium.Chromium.ChromiumDriver.
async Task RemoveInjectedScript (string identifier, string sessionId=null)
 Removes a script previously registered via EnableFetchScriptInjection, using Page.removeScriptToEvaluateOnNewDocument.
async Task< string > InjectScript (string scriptToInject, string sessionId=null)
 Registers a script via EnableFetchScriptInjection and tracks its CDP identifier so it can later be removed by ClearInjectedScripts.
async Task ClearInjectedScripts (string sessionId=null)
 Removes all scripts previously registered via InjectScript.
async Task WaitForEvent (string eventName, TimeSpan timeout)
 Polls the internal CDP event queue until an event named eventName is dequeued or the specified timeout elapses, logging a warning if the timeout is reached without finding a match. Note that any non-matching events dequeued while waiting are discarded.
async Task< bool > WaitForLayoutReady (GPALElement element, string sessionId, int maxWaitMs=3000, int pollIntervalMs=150)
 Polls until the given element's layout has stabilized with non-zero dimensions, first using DOM.getBoxModel (re-resolving the element via EvaluateSelector if it has become detached), and falling back to a JavaScript getBoundingClientRect check if the box model is unavailable.
async Task< string > CreateTarget (string url, bool newWindow=false, string sessionId=null)
 Navigates to a new target by creating a new tab (or, optionally, a new browser window/context), attaching a CDP session to it, and registering it as the active tab via AddTabToQueue. Honors robots.txt rules by redirecting to a fallback URL if the requested URL is disallowed and the browser is configured to obey it.
async Task< string > GetTargetWindowIdByUrl (string url, string sessionId=null)
 Searches every tracked window and tab for one whose underlying CDP target URL contains url , querying Target.getTargetInfo for each tab in turn, and returns the browser context ID of the containing window.
async Task< string > GetTargetTabIdByUrl (string url, string sessionId=null)
 Searches for an open tab whose CDP target URL contains url , checking the tabs of the currently active window first and then all other windows, querying Target.getTargetInfo for each tab (with both the raw and URL-decoded forms of the URL compared for the active window's tabs).
async Task< int > QueryByCss (string selector, string sessionId=null)
 Queries the document for the first element matching the given CSS selector.
async Task SwitchToFrame (string frameSelector)
 Resolves an iframe element matching the given selector and switches the current evaluation context into that iframe by attaching to its frame target (for cross-origin frames) and creating an isolated JavaScript execution world. Subsequent DOM/JS operations will operate inside the iframe until the context is reset.
async Task SwitchToElement (string elementSelector)
 Resolves the shadow root of an element matching the given selector and stores its remote object id so that subsequent selector evaluations can query inside the shadow DOM.
async Task SwitchToShadowDom (string shadowHostSelector)
async Task< List< GPALElement > > EvaluateSelector (string selector, string sessionId=null, bool isRecursive=false)
 Resolves a CSS selector, XPath expression, CDP node id, or remote object id to a list of matching GPALElement instances, including their attributes, bounding rectangle, CSS path and XPath. Handles shadow DOM contexts (via SwitchToShadowDom) and isolated iframe contexts (via SwitchToFrame). If nothing is found and the call is not recursive, it performs a deep search by recursively evaluating the selector inside any iframe targets.
async Task< string > GetCssForElement (int backendNodeId, bool optimized=false, string sessionId=null)
 Generates a CSS selector string that uniquely identifies the element with the given backend node id.
async Task< string > GetXPathForElement (int backendNodeId, bool optimized=true, string sessionId=null)
 Generates an XPath expression that identifies the element with the given backend node id.
async Task< string > GetXPathOrCssForElement (int backendNodeId, string jsFunc, bool optimized, string sessionId)
 Shared helper used by GetCssForElement and GetXPathForElement that resolves the element with the given backend node id to a remote object and invokes the supplied JavaScript function on it to compute a selector or path string.
async Task LeftClickByCss (string selector, string sessionId=null)
 Finds all elements matching the given CSS selector and performs a left click on each of them.
async Task< dynamic > ExecuteJavaScript (string expression, string sessionId=null)
 Evaluates an arbitrary JavaScript expression in the current page context and returns its value.
async Task CaptureCalls (bool capture, string sessionId=null)
 Sets headers to be sent with every request for the rest of the session, which is how a credential that can be settled ahead of a challenge is presented once rather than watched for.
async Task< bool > NavigateToUrl (string url, string sessionId)
async Task< dynamic > Back (string sessionId=null)
 Navigates the page back to the previous entry in its navigation history, if one exists.
async Task< dynamic > CaptureVisibleTab (string sessionId=null)
 Captures a screenshot of the currently visible tab as a PNG image.
async Task CastDesktop (string sinkName, string sessionId)
 Searches for a Cast device with the given sink name and, if found, starts mirroring the entire desktop to it. Retries discovery up to 10 times, waiting between attempts for the device to appear.
async Task CastTab (string sinkName, string sessionId)
 Searches for a Cast device with the given sink name and, if found, starts mirroring the current tab to it. Retries discovery up to 10 times, waiting between attempts for the device to appear.
async Task< bool > StopCasting (string sessionId)
 Attempts to stop an active Cast session for the current sink. Note: there may be no reliable programmatic way to cleanly stop casting other than closing the tab or window.
async Task< bool > CheckNetworkIdle (string sessionId=null, int maxConnections=0, int timeoutMs=30000, int pruneMs=3000, string sessionToken=null)
 Enables network event monitoring and waits until no new network requests have been observed for pruneMs milliseconds, or until timeoutMs elapses. While running, it processes queued network events for diagnostic logging and suppresses normal network event handling.
async Task ClearReferrer (string sessionId=null)
 Clears the Referer header that is sent with subsequent network requests.
async Task< bool > CloseTab (string url=null, string tabId=null, string sessionId=null)
 Closes a browser tab identified by tab id, URL, or (if neither is given) the current tab.
async Task< bool > CloseTab (string targetId, string sessionId=null)
 Closes the browser tab with the given target id, removes it from the internal tab queue, and closes its parent window if that was the last remaining tab.
async Task< bool > CloseWindow (string browserContextId, string sessionId=null)
 Closes all tabs belonging to the browser window with the given browser context id, then removes the window from the internal window queue.
async Task< bool > DeleteStorage (string storageType, string sessionId, string domain=null, string storeName=null, string path=null, string key=null)
 written by chatgpt Deletes browser storage items according to hierarchical wildcard rules. Returns number of items deleted.
async Task< dynamic > Evaluate (string xpath, string sessionId=null)
 Evaluates an XPath expression against the document and returns the first matching node.
async Task< dynamic > EvaluateAll (string xpath, string sessionId=null)
 Evaluates an XPath expression against the document and returns all matching nodes as an array.
async Task< dynamic > FillIn (string objectId, string text, int delayMs=0, string sessionId=null)
 Fills a form field with the given text, trying multiple strategies in order of speed/reliability: bulk text insertion, direct JS value assignment with synthetic events, and finally per-character key events.
async Task FillInAppend (string objectId, string text, int delayMs=0, string sessionId=null)
 Appends text to the end of an element's current value, then fills it in using FillIn.
async Task FillInInsert (string objectId, string text, int delayMs=0, string sessionId=null)
 Inserts text before an element's current value (prepending it), then fills it in using FillIn.
async Task FillInOverwrite (string objectId, string text, int delayMs=0, string sessionId=null)
 Replaces an element's current value entirely with the given text using FillIn.
async Task< dynamic > FireChangeEvent (string objectId, string sessionId=null)
 Dispatches a "change" event on the target element via JavaScript.
async Task Focus (int backendNodeId, string sessionId=null)
 Sets browser focus on the element identified by the given backend node id, using DOM.focus.
async Task< dynamic > Forward (string sessionId=null)
 Navigates forward one entry in the page's navigation history, if a forward entry exists.
async Task< bool > FullScreen (string sessionId=null)
 Full screen the currnet browser window NOTE: in headless mode this is a maximize, there is no way to full screen in headless mode.
async Task< dynamic > GetAttribute (int backendNodeId, string attribute, string sessionId=null)
 Retrieves a single attribute of the element identified by the given backend node id via DOM.getAttributes.
async Task< Rectangle > GetBoundingClientRect (int backendNodeId, string sessionId=null)
 Computes the bounding client rectangle (position and size) of the element identified by the given backend node id, preferring direct JavaScript evaluation in the iframe's context for cross-origin iframes and falling back to DOM.getBoxModel on the main page.
async Task< dynamic > GetContentAndCss (string elementId, string sessionId=null)
 Retrieves the inner HTML content and computed CSS styles of the element with the given DOM id.
async Task< Dictionary< string, object > > GetCssAttributes (int backendNodeId, string sessionId=null)
 Retrieves a filtered set of computed CSS properties (layout/visibility/positioning relevant properties) for the element identified by the given backend node id, via CSS.getComputedStyleForNode.
async Task< Dictionary< string, object > > GetDomAttributes (int backendNodeId, string sessionId=null)
 Retrieves all DOM attributes (name/value pairs) of the element identified by the given backend node id, via DOM.getAttributes.
async Task< Dictionary< string, object > > GetDomProperties (int backendNodeId, string sessionId=null)
 Retrieves DOM node info and JavaScript-side own properties of the element identified by the given backend node id, via DOM.describeNode and Runtime.getProperties.
async Task< string > GetCurrentUrl (string sessionId=null)
 Gets the URL of the currently active page/frame by evaluating window.location.href.
async Task< int > GetCurrentWindow (string sessionId=null)
 Gets the browser window id associated with the current target via Browser.getWindowForTarget.
async Task< System.Drawing.Rectangle > GetWindowRectangle (string sessionId=null)
 Where this browser's window is and how big it is, in screen coordinates, asked of the browser itself rather than of the page. Browser.getWindowBounds answers with the whole window including its chrome, so it needs no JavaScript and works on a page that is still loading.
async Task< dynamic > GetElementAttributeHash (string elementId, string sessionId=null)
 Retrieves a JSON representation of all attributes of the element with the given DOM id.
async Task< string > GetPageSource (string sessionId=null)
 Retrieves the page's document source as raw HTML/XML text, by fetching the root document and its outer HTML via DOM.getDocument and DOM.getOuterHTML. The source is returned raw; normalization (unescaping and stripping Chrome's XML-viewer wrapper) is applied uniformly for all engines in Browser.GetPageSource.
async Task< dynamic > GetParentNode (string elementId, string sessionId=null)
 Retrieves the parent node of the element with the given DOM id.
async Task< string > GetReadyStatus (string sessionId, string sessionToken)
 Gets the current document.readyState of the page, logging the status (and suppressing repeated identical messages within the same session token).
async Task< dynamic > GetShadowRoot (string css, string sessionId=null)
 Locates an element by CSS selector and retrieves a description of its node, including any shadow root, via DOM.describeNode.
async Task< string > GetStorage (string storageType, string sessionId, string domain=null, string storeName=null, string path=null, string key=null)
 written by chatgpt Retrieves browser storage items as raw JSON text. Supports hierarchical wildcards: domain -> storeName -> path -> key.
async Task< string > GetUserAgent (string sessionId=null)
 Gets the browser's user agent string by evaluating navigator.userAgent.
async Task< bool > GoTo (string url, string sessionId=null)
 Navigates the current page/tab to the given URL.
async Task< string > GoToTab (object tabIdOrUrlOrIndex, string sessionId=null)
 Switches the active tab to the one identified by the given index, target id, or URL.
async Task< dynamic > HideElement (int backendNodeId, string sessionId=null)
 Hides the element identified by the given backend node id by setting its inline style to "display: none".
async Task Hover (int backendNodeId, string sessionId=null)
 Moves the mouse pointer to a random point within the element identified by the given backend node id, dispatching an Input.dispatchMouseEvent "mouseMoved" event.
async Task< bool > IsClickable (string elementId, string sessionId=null)
 Determines whether the element with the given DOM id is clickable, using the browser's checkVisibility() API.
async Task< bool > IsDisplayed (string elementId, string sessionId=null)
 Determines whether the element with the given DOM id is displayed, by checking that its offsetParent is not null.
async Task< bool > IsEnabled (string elementId, string sessionId=null)
 Determines whether the element with the given DOM id is enabled, by checking that its disabled property is false.
async Task< bool > IsEndOfPage (string sessionId=null)
 Determines whether the page (or its nearest scrollable element) is scrolled to its end, taking into account the document's overflow style.
async Task< bool > ElementFromPoint (GPALElement element, int x, int y, string sessionId=null)
 Determines whether one or more elements are fully within the current viewport bounds, based on their bounding client rectangles compared against the window's inner dimensions.
async Task< bool > IsVisibleInViewport (dynamic elemsOrBackendNodeId, string sessionId=null)
async Task ClickElement (GPALElement element, string sessionId, List< dynamic > responses, ClickType clickType=ClickType.LeftClick, int modifiers=0)
 Performs a click (or other configured click type) on the given element, using CDP input dispatch, with a JavaScript-based fallback for cases (such as headless mode) where the box model cannot be obtained.
async Task DragAndDrop (GPALElement element, string sessionId, List< dynamic > responses, int deltaX, int deltaY, int offsetX=0, int offsetY=0)
 Drags element by (deltaX , deltaY ) pixels from its current center, by dispatching a mousePressed/mouseMoved.../mouseReleased sequence via CDP Input.dispatchMouseEvent.
async Task LeftClick (string elementId, string sessionId=null)
 Performs a left mouse click on the element(s) matching the given selector. Scrolls each matching element into view before clicking. Implementation for the "left-click" workflow action.
async Task SetDownloadBehavior (string downloadPath, string sessionId=null)
 Accept downloads into downloadPath without asking where to put them.
Browser scoped rather than page scoped, so it holds for every tab opened afterwards, which is what a url fetched into a new tab depends on.
This has to be done over CDP because the Save dialog is a profile preference fixed when the browser launched, and MagicHelper.LaunchBrowser only writes that preference when it builds the profile itself. Hand it an existing profile and the preference is never applied.
async Task RestoreDownloadBehavior (string sessionId=null)
 Hands the download directory back to the browser, so a profile the workflow borrowed is not left saving everything the user downloads afterwards into the workflow's folder.
CDP has no way to read the directory that was in force, but "default" means the browser's own setting, whatever that is, which is exactly where it should end up.
async Task LeftClickAndDownload (List< GPALElement > elems, string downloadPath, int modifiers, string sessionId, List< dynamic > responses)
 Performs a left click on each element in elems to trigger a file download (headless mode). Sets the browser-level download behavior to the directory containing downloadPath before clicking. The actual filename cannot be controlled here, so a download watcher is required to detect the resulting file. Implementation for the "left-click-download" workflow action. Headless only.
async Task LeftClickAndUpload (List< GPALElement > elems, object uploadFiles, int modifiers, string sessionId, List< dynamic > responses)
 Attaches one or more files to file input element(s) using CDP. Supports single file path (string) or multiple paths (List<string> / IEnumerable<string>). Accumulates files across calls by tracking attached paths per session/input and re-attaching the full list each time. Uses DOM.setFileInputFiles to set files directly (headless-friendly, no dialog). Dispatches change event after attachment to trigger page/widget processing.
async Task LeftDoubleClick (string elementId, string sessionId=null)
 Performs a left mouse double-click on the element(s) matching the given selector. Scrolls each matching element into view before double-clicking. Implementation for the "left-double-click" workflow action.
async Task< bool > Maximize (string sessionId=null)
 Maximizes the browser window so it fills the primary screen. Implementation for the "maximize" workflow action.
async Task< bool > Minimize (string sessionId=null)
 Minimizes the browser window. Implementation for the "minimize" workflow action.
async Task< bool > MoveTo (List< GPALElement > elems, string sessionId, List< dynamic > responses)
 Moves the mouse pointer to a randomized point within each given element's bounding box (clicking dead-center for anchor/"A" elements), scrolling each element into view first. Used as a humanization step before interacting with elements.
async Task MoveTo (int backendNodeId, string sessionId=null)
 Moves the mouse pointer to a randomized point within the element identified by backendNodeId . Implementation for the "move-to" workflow action.
async Task ClickElement (int x, int y, string sessionId, List< dynamic > responses, ClickType clickType=ClickType.LeftClick, int modifiers=0)
 Clicks a viewport coordinate rather than an element, for targets with no DOM handle at all - an image match being the case that needs it. Moves first so the renderer's hover state is correct, then presses and releases, mirroring what the element click does once it has resolved its box model.
async Task MoveTo (int x, int y, string sessionId=null)
 Moves the mouse pointer to a viewport coordinate rather than to an element, for targets that have no DOM handle at all - an image match being the case that needs it. This is a real browser level input event, so unlike a dispatched mouseover it does update the renderer's CSS :hover state.
async Task< string > NewTab (GPALUrl url=null, string sessionId=null)
 Opens a new background tab in the currently active window and navigates it to the given URL. Resolves the URL via the magic helper, honors robots.txt restrictions when configured, and registers the new target/tab in the active window's tab queue. Implementation for the "new-tab" workflow action.
async Task< string > NextTab (string currentTargetId)
 Switches the active tab in the current window to the next tab in the tab queue (wrapping around). Before switching, polls CDP for all targets to discover and register any tabs not yet in the queue. Implementation for the "next-tab" workflow action.
async Task< string > NextWindow (string currentTargetId)
 Switches the active browser window/context to the next window in the window queue (wrapping around), activating that window's currently active tab and re-attaching the CDP session if needed. Implementation for the "next-window" workflow action.
async Task< bool > Normal (string sessionId=null)
 Restores the browser window to its normal (non-maximized, non-minimized) state. Implementation for the "normal" workflow action.
async Task< string > OpenWindow (string url="https://google.com", string sessionId=null)
 Opens a brand new browser window (its own browser context) navigated to the given URL, activates and attaches to it via CDP, and registers it as the new active window with its own tab queue. Implementation for the "open-window" workflow action.
async Task OverrideReferrer (string url, string sessionId=null)
 Overrides the HTTP Referer header sent with subsequent requests to the given URL. Implementation for the "override-referrer" workflow action.
async Task< dynamic > SetUserAgent (string userAgent, string sessionId=null)
 Overrides the browser's user agent string (including navigator.userAgent) for subsequent requests. Implementation for the "set-useragent" workflow action.
async Task PageDown (int pagesToScroll=1, string sessionId=null)
 Scrolls the page down by one or more page heights. Implementation for the "page-down" workflow action.
async Task PageEnd (string sessionId=null)
 Scrolls to the very bottom of the page. Implementation for the "page-end" workflow action.
async Task PageTop (string sessionId=null)
 Scrolls to the very top of the page. Implementation for the "page-top" workflow action.
async Task PageUp (int pagesToScroll=1, string sessionId=null)
 Scrolls the page up by one or more page heights. Implementation for the "page-up" workflow action.
async Task PressModifierKey (int modifierKeys, string sessionId=null)
 Dispatches a key-down event for the given modifier key(s) without a corresponding key-up, leaving the modifier(s) "held" for subsequent input events. Implementation for the "press-modifier-key" workflow action.
async Task< string > PreviousTab (string currentTargetId)
 Switches the active tab in the current window to the previous tab in the tab queue (wrapping around). Before switching, polls CDP for all targets to discover and register any tabs not yet in the queue, updates the window's active tab index, and re-attaches the CDP session if needed. Implementation for the "previous-tab" workflow action.
async Task< string > PreviousWindow (string currentTargetId)
 Switches the active browser window/context to the previous window in the window queue (wrapping around), activating that window's currently active tab and re-attaching the CDP session if needed. Implementation for the "previous-window" workflow action.
async Task< dynamic > QuerySelector (string css, string sessionId=null)
 Finds the first element matching the given CSS selector. Implementation for the "query-selector" workflow action.
async Task< dynamic > QuerySelectors (string css, string sessionId=null)
 Finds all elements matching the given CSS selector, starting from the document root. Implementation for the "query-selectors" workflow action.
async Task Refresh (string sessionId=null)
 Reloads the current page. Implementation for the "refresh" workflow action.
async Task ReleaseModifierKey (int modifierKeys, string sessionId=null)
 Dispatches a key-up event for the given modifier key(s), releasing modifier(s) previously held via PressModifierKey. Implementation for the "release-modifier-key" workflow action.
async Task< bool > Restore (string sessionId=null)
 Restores the browser window to its normal (non-maximized, non-minimized) window state. Implementation for the "restore" workflow action.
async Task MiddleClick (string elementId, string sessionId=null)
 Performs a middle mouse click on the element(s) matching the given selector. Scrolls each matching element into view before clicking. Implementation for the "middle-click" workflow action.
async Task RightClick (string elementId, string sessionId=null)
 Performs a right mouse click on the element(s) matching the given selector. Scrolls each matching element into view before clicking. Implementation for the "right-click" workflow action.
async Task RightClickAndDownload (string elementId, string savePath, string sessionId=null)
 Configures the page-level download behavior to save to savePath , then performs a right click on the element(s) matching the given selector to trigger a "Save link as" style download. Implementation for the "right-click-download" workflow action.
async Task ScrollElement (string elementId, int hPixels, int vPixels, string sessionId=null)
 Scrolls the element with the given DOM id by the specified number of pixels horizontally and vertically, using Element.scrollBy. Implementation for the "scroll-element" workflow action.
async Task< bool > ScrollIntoView (GPALElement element, string sessionId=null)
 Scrolls the given element into the viewport, first attempting the native CDP DOM.scrollIntoViewIfNeeded command and falling back to a JavaScript Element.scrollIntoView call if the native command does not return a result. In headless mode, also forces a layout reflow before and a brief delay after scrolling, and injects a one-time stylesheet disabling overscroll bounce so elements don't shift after scrolling. Implementation for the "scroll-into-view" workflow action.
async Task ScrollWindow (int hPixels, int vPixels, string sessionId=null)
 Scrolls the whole window/viewport by the specified number of pixels horizontally and vertically, then waits briefly to allow headless rendering to settle. Implementation for the "scroll-window" workflow action.
async Task< dynamic > SendKey (string key, string code, int vkCode, string sessionId=null)
 Dispatches a full key press sequence (keydown, optional char, keyup) for the given key via CDP, using "\r" as the char payload for the Enter key so forms submit correctly, and the literal character for single-character keys. Implementation for the "send-key" workflow action.
async Task SendString (string text, int delayMs=0, string sessionId=null)
 Sends the given text at the current focus/cursor position. With delayMs equal to 0 (the default), the whole string is inserted atomically via CDP's Input.insertText. When delayMs is greater than 0, the text is dispatched character-by-character via DispatchTextCharByChar, sleeping delayMs milliseconds between characters. Implementation for the "send-string" workflow action (equivalent to "fill-in").
async Task< dynamic > SetAttribute (int backendNodeId, string attribute, string value, string sessionId=null)
 Sets the value of an HTML attribute on the element identified by backendNodeId . Implementation for the "set-attribute" workflow action.
async Task SetDownloadFilename (string downloadPath, string sessionId=null)
 Configures the page-level download behavior so that future downloads are saved to the given path. Implementation for the "set-download-filename" workflow action.
async Task< dynamic > SetRange (string elementId, string rangeValue, string sessionId=null)
 Sets the value of the element matching the given CSS selector and dispatches "input" and "change" events so the page reacts to the new value (e.g. for range/slider inputs). Implementation for the "set-range" workflow action.
async Task TopBrowser (string sessionId=null)
 Brings the current page/tab to the front of the operating system's window stack. Implementation for the "top-browser" workflow action.
async Task< bool > SetStorage (string storageType, string sessionId, string domain, string key, string data, string storeName=null, string path=null)
 Sets a value in browser storage. Required parameters must be supplied. Returns "success" if write completed, null if failed.
async Task< dynamic > SetValueFromElement (string srcCss, string destCss, string sessionId=null)
 Copies the value from a source element into a destination element by setting destElement.value = srcElement.value via JavaScript evaluation, then dispatches "input" and "change" events on the destination so the page reacts to the new value. Implementation for the "set-value-from-element" workflow action.
async Task StealthOverrideReferrer (string sessionId=null)
 Overrides the HTTP Referer header for subsequent requests to "https://www.google.com", used to make navigation appear as if it originated from a Google search. Implementation for the "stealth-override-referrer" workflow action.
async Task< dynamic > SubmitForm (string objectId, string sessionId=null)
 Submits the HTML form represented by the given remote object by invoking its submit() method.
Task SwitchToDefaultContent (string sessionId=null)
 Switches the active context back to the top-level page document, clearing any current iframe/shadow root context.
async Task< string > GoToWindow (object tabIdOrUrl, string sessionId=null)
 Switches the active tab/window to the one identified by a tab index or page URL, activating the corresponding CDP target and updating the active window/tab indices.
async Task< int > WindowInnerHeight (string sessionId=null)
 Gets the height of the browser window's viewport (window.innerHeight), in pixels.
async Task< int > WindowInnerWidth (string sessionId=null)
 Gets the width of the browser window's viewport (window.innerWidth), in pixels.
async Task< int > WindowOuterHeight (string sessionId=null)
 Gets the outer height of the browser window (window.outerHeight), including browser chrome, in pixels.
async Task< int > WindowOuterWidth (string sessionId=null)
 Gets the outer width of the browser window (window.outerWidth), including browser chrome, in pixels.
async Task< string > Fetch (string url, string method=null, string body=null, string contentType=null, string[] headers=null, bool asBytes=false, string sessionId=null)
 Issues a GPALRequest from inside the page, so the browser's own socket carries it: same cookies, same TLS fingerprint, same header order, same anti-bot clearance. A relative path resolves against wherever the browser currently is, which is what a site proxying its own API needs.
async Task< int > WindowPageOffsetX (string sessionId=null)
 Gets the horizontal scroll offset of the page (window.pageXOffset), in pixels.
async Task< int > WindowPageOffsetY (string sessionId=null)
 Gets the vertical scroll offset of the page (window.pageYOffset), in pixels.
async Task< int > WindowScreenLeft (string sessionId=null)
 Gets the horizontal position of the browser window relative to the screen (window.screenLeft), in pixels.
async Task< int > WindowScreenTop (string sessionId=null)
 Gets the vertical position of the browser window relative to the screen (window.screenTop), in pixels.
async Task< string > GetObjectIdFromBackendNodeId (int backendNodeId, string sessionId=null, long? contextId=null)
 Resolves a backendNodeId to a RemoteObject objectId in the correct session and context (main page or iframe).
string GetEffectiveSessionId ()
 Gets the session ID that should be used for the current operation, preferring the current iframe session (if inside an iframe) and otherwise falling back to the active tab's session.
string GetCurrentSessionId ()
string GetCurrentTargetId ()
 Gets the CDP target ID of the active tab in the active window.
string GetCurrentWindowTargetId ()
 Gets the browser context ID (window ID) of the active window.
int GetCurrentWindowIndex (string targetId)
 Finds the index of the window whose tab queue contains the given target ID.
async Task< bool > ScrollPageAsync (string direction, int pagesToScroll, string s)
 Scrolls the page up or down by one or more "pages" (the viewport height), trying window.scrollBy first and falling back to scrolling the nearest scrollable element (and finally a Page Up/Down key press) for single-page applications where the document itself does not scroll.
async Task< bool > ScrollToPositionAsync (string position, string s)
 Scrolls the page to the very top or very bottom, trying window.scrollTo first, then the nearest scrollable element's scrollTo, and finally a Home/End key press as a last resort.
async Task< bool > ScrollWindowByPixelsAsync (int hPixels, int vPixels, string sessionId)
 Scrolls the page or the nearest scrollable element by the given relative pixel offsets, trying window.scrollBy first, then an element's scrollBy, and finally falling back to Input.synthesizeScrollGesture (a touch-based scroll gesture).
async Task< bool > SelectByValue (string ElementHandle, string value, string sessionId=null)
 Sets the value of an input or select element to the given value and dispatches "input" and "change" events so that page scripts react to the change.
async Task< bool > SelectByIndex (string ElementHandle, int index, string sessionId=null)
 Selects an option in a <select> element by its zero-based index and dispatches "input" and "change" events so that page scripts react to the change.

Properties

string webSocketUrl [get]
int ServerResponseCode [get, set]
 server response code from last operation
ConcurrentQueue< KeyValuePair< string, string > > CurrentSessions [get]
 Queue of (sessionId, targetId) pairs for tabs in the currently active window.
string CurrentTargetID [get]
 The target id of the PuppeteerClient's currently selected tab/session.

Detailed Description

Definition at line 60 of file PuppeteerCommunicator.cs.

Constructor & Destructor Documentation

◆ PuppeteerCommunicator()

GenerallyPositive.Browser.PuppeteerCommunicator.PuppeteerCommunicator ( )

Definition at line 279 of file PuppeteerCommunicator.cs.

Member Function Documentation

◆ Back()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.Back ( string sessionId = null)

Navigates the page back to the previous entry in its navigation history, if one exists.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the navigation result, or null if there is no previous history entry.
await communicator.Back();

Definition at line 3107 of file PuppeteerCommunicator.cs.

◆ CaptureCalls()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.CaptureCalls ( bool capture,
string sessionId = null )

Sets headers to be sent with every request for the rest of the session, which is how a credential that can be settled ahead of a challenge is presented once rather than watched for.

Parameters
headersHeader names and values to send with every request.
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task representing the asynchronous call.

Turns the Network domain on so requests are reported, and starts or stops recording them.

Parameters
captureTrue to record what the page asks for, false to stop
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task representing the asynchronous call.

Starts or stops recording what the browser asks for, reported over the DevTools protocol. Every session GPAL knows about is told, not only the active tab, because a click that opens a tab is exactly the request worth seeing.

await browser.PuppeteerCommunicator.CaptureCalls(true);

Parameters
captureTrue to record, false to stop
sessionIdThe session to tell, or null for every session known

Definition at line 2981 of file PuppeteerCommunicator.cs.

◆ CaptureVisibleTab()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.CaptureVisibleTab ( string sessionId = null)

Captures a screenshot of the currently visible tab as a PNG image.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the CDP screenshot result, including the base64-encoded image data.

Definition at line 3131 of file PuppeteerCommunicator.cs.

◆ CastDesktop()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.CastDesktop ( string sinkName,
string sessionId )

Searches for a Cast device with the given sink name and, if found, starts mirroring the entire desktop to it. Retries discovery up to 10 times, waiting between attempts for the device to appear.

Parameters
sinkNameThe display name of the Cast sink/device to mirror to.
sessionIdCDP session id; the effective session is used if null.
await communicator.CastDesktop("Living Room TV", sessionId);

Definition at line 3149 of file PuppeteerCommunicator.cs.

◆ CastTab()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.CastTab ( string sinkName,
string sessionId )

Searches for a Cast device with the given sink name and, if found, starts mirroring the current tab to it. Retries discovery up to 10 times, waiting between attempts for the device to appear.

Parameters
sinkNameThe display name of the Cast sink/device to mirror to.
sessionIdCDP session id; the effective session is used if null.
await communicator.CastTab("Living Room TV", sessionId);

Definition at line 3194 of file PuppeteerCommunicator.cs.

◆ CheckNetworkIdle()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.CheckNetworkIdle ( string sessionId = null,
int maxConnections = 0,
int timeoutMs = 30000,
int pruneMs = 3000,
string sessionToken = null )

Enables network event monitoring and waits until no new network requests have been observed for pruneMs milliseconds, or until timeoutMs elapses. While running, it processes queued network events for diagnostic logging and suppresses normal network event handling.

Parameters
sessionIdCDP session id; the effective session is used if null.
maxConnectionsReserved for future use; currently not enforced.
timeoutMsThe maximum total time, in milliseconds, to wait for the network to become idle.
pruneMsThe duration of inactivity, in milliseconds, required to consider the network idle.
sessionTokenAn opaque token used to deduplicate repeated status messages across calls.
Returns
Task that resolves to true if the network became idle within the timeout, otherwise false.

Definition at line 3265 of file PuppeteerCommunicator.cs.

◆ ClearCapturedCalls()

void GenerallyPositive.Browser.PuppeteerCommunicator.ClearCapturedCalls ( )

Forgets everything recorded so far. Recording carries on.

Definition at line 182 of file PuppeteerCommunicator.cs.

◆ ClearInjectedScripts()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.ClearInjectedScripts ( string sessionId = null)

Removes all scripts previously registered via InjectScript.

Definition at line 1039 of file PuppeteerCommunicator.cs.

◆ ClearReferrer()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.ClearReferrer ( string sessionId = null)

Clears the Referer header that is sent with subsequent network requests.

Parameters
sessionIdCDP session id; the effective session is used if null.

Definition at line 3407 of file PuppeteerCommunicator.cs.

◆ ClickElement() [1/2]

async Task GenerallyPositive.Browser.PuppeteerCommunicator.ClickElement ( GPALElement element,
string sessionId,
List< dynamic > responses,
ClickType clickType = ClickType::LeftClick,
int modifiers = 0 )

Performs a click (or other configured click type) on the given element, using CDP input dispatch, with a JavaScript-based fallback for cases (such as headless mode) where the box model cannot be obtained.

Parameters
elementThe element to click, including its backend node id and bounding information.
sessionIdCDP session id; used to resolve the effective session, including iframe sessions.
responsesA list to which intermediate command responses are appended.
clickTypeThe type of click to perform (e.g. left click, double click, right click).
modifiersBitmask of keyboard modifier keys (Alt, Ctrl, Meta, Shift) to hold during the click.

Definition at line 5918 of file PuppeteerCommunicator.cs.

◆ ClickElement() [2/2]

async Task GenerallyPositive.Browser.PuppeteerCommunicator.ClickElement ( int x,
int y,
string sessionId,
List< dynamic > responses,
ClickType clickType = ClickType::LeftClick,
int modifiers = 0 )

Clicks a viewport coordinate rather than an element, for targets with no DOM handle at all - an image match being the case that needs it. Moves first so the renderer's hover state is correct, then presses and releases, mirroring what the element click does once it has resolved its box model.

Parameters
xViewport x coordinate, in CSS pixels.
yViewport y coordinate, in CSS pixels.
sessionIdCDP session ID; falls back to the current effective session if null.
responsesList collecting the raw CDP responses from the press and release.
clickTypeWhich button, and whether this is a double click.
modifiersKeyboard modifier flags applied to the click.
Returns
Task representing the asynchronous click operation.

Definition at line 6567 of file PuppeteerCommunicator.cs.

◆ CloseTab() [1/2]

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.CloseTab ( string targetId,
string sessionId = null )

Closes the browser tab with the given target id, removes it from the internal tab queue, and closes its parent window if that was the last remaining tab.

Parameters
targetIdThe CDP target id of the tab to close.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the tab was closed (and the parent window closed, if it became empty), otherwise false.

Definition at line 3450 of file PuppeteerCommunicator.cs.

◆ CloseTab() [2/2]

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.CloseTab ( string url = null,
string tabId = null,
string sessionId = null )

Closes a browser tab identified by tab id, URL, or (if neither is given) the current tab.

Parameters
urlOptional URL used to look up the target tab id if tabId is not provided.
tabIdOptional target id of the tab to close.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the tab (and possibly its now-empty window) was closed successfully.
await communicator.CloseTab(url: "https://example.com");

Definition at line 3437 of file PuppeteerCommunicator.cs.

◆ CloseWindow()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.CloseWindow ( string browserContextId,
string sessionId = null )

Closes all tabs belonging to the browser window with the given browser context id, then removes the window from the internal window queue.

Parameters
browserContextIdThe browser context id identifying the window to close.
sessionIdCDP session id; currently unused but reserved for future use.
Returns
Task that resolves to true if the window and all its tabs were closed successfully, otherwise false.
await communicator.CloseWindow(browserContextId);

Definition at line 3500 of file PuppeteerCommunicator.cs.

◆ CreateTarget()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.CreateTarget ( string url,
bool newWindow = false,
string sessionId = null )

Navigates to a new target by creating a new tab (or, optionally, a new browser window/context), attaching a CDP session to it, and registering it as the active tab via AddTabToQueue. Honors robots.txt rules by redirecting to a fallback URL if the requested URL is disallowed and the browser is configured to obey it.

Parameters
urlThe URL to navigate the new target to (normalized/completed via GPAL.MagicHelper.GetFullUrl).
newWindowIf true, the new target is created in a brand new browser context (window) rather than the current one.
sessionIdThe CDP session used to issue the creation commands; if null, the effective session ID is resolved automatically.
Returns
A task that resolves to the CDP target ID of the newly created tab.
string targetId = await communicator.CreateTarget("https://example.com", newWindow: true);

Definition at line 1791 of file PuppeteerCommunicator.cs.

◆ DeleteStorage()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.DeleteStorage ( string storageType,
string sessionId,
string domain = null,
string storeName = null,
string path = null,
string key = null )

written by chatgpt Deletes browser storage items according to hierarchical wildcard rules. Returns number of items deleted.

Wildcard rules (null parameters):

  • domain = null : delete all domains (if supported)
  • storeName = null : delete all object stores (IndexedDB)
  • path = null : delete all paths (cookies)
  • key = null : delete all keys
  • key != null : delete single key

ERROR events are published if required parameters are missing.

Parameters
storageTypeStorage type
sessionIdCDP session id
domainDomain/origin; null acts as wildcard
storeNameOptional object store (IndexedDB)
pathOptional path (cookies)
keyOptional key; null acts as wildcard
Returns
Number of items successfully deleted

Definition at line 3564 of file PuppeteerCommunicator.cs.

◆ DragAndDrop()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.DragAndDrop ( GPALElement element,
string sessionId,
List< dynamic > responses,
int deltaX,
int deltaY,
int offsetX = 0,
int offsetY = 0 )

Drags element by (deltaX , deltaY ) pixels from its current center, by dispatching a mousePressed/mouseMoved.../mouseReleased sequence via CDP Input.dispatchMouseEvent.

Parameters
elementThe element to drag, including its bounding rect.
sessionIdCDP session id; used as-is for each dispatched command.
responsesA list to which intermediate command responses are appended.
deltaXHorizontal drag distance in pixels from the element's center.
deltaYVertical drag distance in pixels from the element's center.

Definition at line 6153 of file PuppeteerCommunicator.cs.

◆ ElementFromPoint()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.ElementFromPoint ( GPALElement element,
int x,
int y,
string sessionId = null )

Determines whether one or more elements are fully within the current viewport bounds, based on their bounding client rectangles compared against the window's inner dimensions.

Parameters
elemsOrBackendNodeIdEither a List<GPALElement> of elements to check, or a single backend node id.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the element(s) are within the viewport (or if their bounding rectangle could not be determined, fail-forward true), otherwise false.

Whether a click at this viewport point would reach the element, or land on whatever is covering it.
The element's box says where it is, not whether anything is on top of it there. A descendant counts, since clicking the text inside a button is clicking the button.

Parameters
elementThe element that should receive the click
xViewport x
yViewport y
sessionIdCDP session ID; falls back to the current effective session if null
Returns
True when the element, or something inside it, is what is at that point

Definition at line 5815 of file PuppeteerCommunicator.cs.

◆ EnableFetchScriptInjection()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.EnableFetchScriptInjection ( string scriptToInject,
string sessionId = null )

Registers a JavaScript snippet to be evaluated automatically on every new document load for the given session, using Page.addScriptToEvaluateOnNewDocument. When Puppeteer is not in use, the equivalent Selenium Chromium CDP command is issued instead via the underlying OpenQA.Selenium.Chromium.ChromiumDriver.

Parameters
scriptToInjectThe JavaScript source code to run on each new document.
sessionIdThe CDP session (or target ID) to inject the script into; if null, the effective session ID is resolved automatically.
Returns
A task that completes with the CDP-assigned script identifier (for later removal via RemoveInjectedScript), or throws if the CDP/Selenium command fails.

Definition at line 951 of file PuppeteerCommunicator.cs.

◆ Evaluate()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.Evaluate ( string xpath,
string sessionId = null )

Evaluates an XPath expression against the document and returns the first matching node.

Parameters
xpathThe XPath expression to evaluate.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the CDP Runtime.evaluate result for the first matching node, or null if none match.
await communicator.Evaluate("//button[@id='submit']");

Definition at line 3848 of file PuppeteerCommunicator.cs.

◆ EvaluateAll()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.EvaluateAll ( string xpath,
string sessionId = null )

Evaluates an XPath expression against the document and returns all matching nodes as an array.

Parameters
xpathThe XPath expression to evaluate.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the CDP Runtime.evaluate result containing an array of all matching nodes.
await communicator.EvaluateAll("//a[@class='item']");

Definition at line 3870 of file PuppeteerCommunicator.cs.

◆ EvaluateSelector()

async Task< List< GPALElement > > GenerallyPositive.Browser.PuppeteerCommunicator.EvaluateSelector ( string selector,
string sessionId = null,
bool isRecursive = false )

Resolves a CSS selector, XPath expression, CDP node id, or remote object id to a list of matching GPALElement instances, including their attributes, bounding rectangle, CSS path and XPath. Handles shadow DOM contexts (via SwitchToShadowDom) and isolated iframe contexts (via SwitchToFrame). If nothing is found and the call is not recursive, it performs a deep search by recursively evaluating the selector inside any iframe targets.

Parameters
selectorA CSS selector, XPath expression, numeric node id, or CDP remote object id.
sessionIdCDP session id; the effective session (or current session, if inside an isolated iframe context) is used if null.
isRecursiveTrue when this call is a recursive deep search inside an iframe; suppresses the outer iframe search and the evaluation semaphore.
Returns
Task that resolves to the list of matching elements, or an empty list if none were found or an error occurred.

Definition at line 2245 of file PuppeteerCommunicator.cs.

◆ ExecuteJavaScript()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.ExecuteJavaScript ( string expression,
string sessionId = null )

Evaluates an arbitrary JavaScript expression in the current page context and returns its value.

Parameters
expressionThe JavaScript expression to evaluate.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the CDP Runtime.evaluate result, including the returned value.

Definition at line 2934 of file PuppeteerCommunicator.cs.

◆ Fetch()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.Fetch ( string url,
string method = null,
string body = null,
string contentType = null,
string[] headers = null,
bool asBytes = false,
string sessionId = null )

Issues a GPALRequest from inside the page, so the browser's own socket carries it: same cookies, same TLS fingerprint, same header order, same anti-bot clearance. A relative path resolves against wherever the browser currently is, which is what a site proxying its own API needs.

Parameters
urlUrl to request. A relative one resolves against wherever the browser currently is.
methodHTTP method, GET when null.
bodyRequest body, or null for none.
contentTypeContent type of the body.
headersExtra request headers, flattened to name, value, name, value.
asBytesTrue to bring the body back base64 encoded, which is what a file needs.
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the response envelope, or null if the fetch could not be made.

Definition at line 8361 of file PuppeteerCommunicator.cs.

◆ FillIn()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.FillIn ( string objectId,
string text,
int delayMs = 0,
string sessionId = null )

Fills a form field with the given text, trying multiple strategies in order of speed/reliability: bulk text insertion, direct JS value assignment with synthetic events, and finally per-character key events.

Parameters
objectIdRemote object id of the input/textarea element.
textThe text to type into the element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the text was successfully filled in, otherwise false.
await communicator.FillIn(inputObjectId, "hello@example.com");

Definition at line 3979 of file PuppeteerCommunicator.cs.

◆ FillInAppend()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.FillInAppend ( string objectId,
string text,
int delayMs = 0,
string sessionId = null )

Appends text to the end of an element's current value, then fills it in using FillIn.

Parameters
objectIdRemote object id of the input/textarea element.
textThe text to append after the element's existing value.
sessionIdCDP session id; the effective session is used if null.
await communicator.FillInAppend(inputObjectId, "-suffix");

Definition at line 4187 of file PuppeteerCommunicator.cs.

◆ FillInInsert()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.FillInInsert ( string objectId,
string text,
int delayMs = 0,
string sessionId = null )

Inserts text before an element's current value (prepending it), then fills it in using FillIn.

Parameters
objectIdRemote object id of the input/textarea element.
textThe text to insert before the element's existing value.
sessionIdCDP session id; the effective session is used if null.
await communicator.FillInInsert(inputObjectId, "prefix-");

Definition at line 4215 of file PuppeteerCommunicator.cs.

◆ FillInOverwrite()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.FillInOverwrite ( string objectId,
string text,
int delayMs = 0,
string sessionId = null )

Replaces an element's current value entirely with the given text using FillIn.

Parameters
objectIdRemote object id of the input/textarea element.
textThe text that will become the element's new value.
sessionIdCDP session id; the effective session is used if null.
await communicator.FillInOverwrite(inputObjectId, "new value");

Definition at line 4243 of file PuppeteerCommunicator.cs.

◆ FireChangeEvent()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.FireChangeEvent ( string objectId,
string sessionId = null )

Dispatches a "change" event on the target element via JavaScript.

Parameters
objectIdRemote object id of the target element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the raw response from the Runtime.callFunctionOn command.

Definition at line 4255 of file PuppeteerCommunicator.cs.

◆ Focus()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.Focus ( int backendNodeId,
string sessionId = null )

Sets browser focus on the element identified by the given backend node id, using DOM.focus.

Parameters
backendNodeIdThe CDP backend node id of the element to focus.
sessionIdCDP session id; the effective session is used if null.

Definition at line 4272 of file PuppeteerCommunicator.cs.

◆ Forward()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.Forward ( string sessionId = null)

Navigates forward one entry in the page's navigation history, if a forward entry exists.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the result of navigating to the next history entry, or null if there is no forward entry.

Definition at line 4285 of file PuppeteerCommunicator.cs.

◆ FullScreen()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.FullScreen ( string sessionId = null)

Full screen the currnet browser window NOTE: in headless mode this is a maximize, there is no way to full screen in headless mode.

Parameters
sessionId
Returns

Definition at line 4310 of file PuppeteerCommunicator.cs.

◆ GetAttribute()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.GetAttribute ( int backendNodeId,
string attribute,
string sessionId = null )

Retrieves a single attribute of the element identified by the given backend node id via DOM.getAttributes.

Parameters
backendNodeIdThe CDP backend node id of the element.
attributeThe name of the attribute to retrieve.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the raw response from the DOM.getAttributes command.

Definition at line 4338 of file PuppeteerCommunicator.cs.

◆ GetBoundingClientRect()

async Task< Rectangle > GenerallyPositive.Browser.PuppeteerCommunicator.GetBoundingClientRect ( int backendNodeId,
string sessionId = null )

Computes the bounding client rectangle (position and size) of the element identified by the given backend node id, preferring direct JavaScript evaluation in the iframe's context for cross-origin iframes and falling back to DOM.getBoxModel on the main page.

Parameters
backendNodeIdThe CDP backend node id of the element.
sessionIdCDP session id; the effective session, or the current iframe session, is used if applicable.
Returns
Task that resolves to the element's bounding rectangle, or (-1, -1, -1, -1) if it could not be determined.

Definition at line 4355 of file PuppeteerCommunicator.cs.

◆ GetCapturedCalls()

List< GPALCall > GenerallyPositive.Browser.PuppeteerCommunicator.GetCapturedCalls ( )

Everything recorded so far, oldest first. A copy, so reading it is never reading what the browser is still writing. List<GPALCall> calls = browser.PuppeteerCommunicator.GetCapturedCalls();.

Returns
The calls recorded so far, empty when nothing was captured

Definition at line 174 of file PuppeteerCommunicator.cs.

◆ GetContentAndCss()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.GetContentAndCss ( string elementId,
string sessionId = null )

Retrieves the inner HTML content and computed CSS styles of the element with the given DOM id.

Parameters
elementIdThe HTML "id" attribute value of the target element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the raw response from the Runtime.evaluate command, containing the element's content and CSS as a JSON string.

Definition at line 4455 of file PuppeteerCommunicator.cs.

◆ GetCssAttributes()

async Task< Dictionary< string, object > > GenerallyPositive.Browser.PuppeteerCommunicator.GetCssAttributes ( int backendNodeId,
string sessionId = null )

Retrieves a filtered set of computed CSS properties (layout/visibility/positioning relevant properties) for the element identified by the given backend node id, via CSS.getComputedStyleForNode.

Parameters
backendNodeIdThe CDP backend node id of the element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to a dictionary of relevant, non-default CSS property names and values, or null on failure.

Definition at line 4472 of file PuppeteerCommunicator.cs.

◆ GetCssForElement()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetCssForElement ( int backendNodeId,
bool optimized = false,
string sessionId = null )

Generates a CSS selector string that uniquely identifies the element with the given backend node id.

Parameters
backendNodeIdThe CDP backend node id of the element.
optimizedWhether to prefer a shorter, optimized selector (e.g. using the element's id) when possible.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the generated CSS selector, or an empty string if it could not be determined.

Definition at line 2687 of file PuppeteerCommunicator.cs.

◆ GetCurrentSessionId()

string GenerallyPositive.Browser.PuppeteerCommunicator.GetCurrentSessionId ( )

Definition at line 8643 of file PuppeteerCommunicator.cs.

◆ GetCurrentTargetId()

string GenerallyPositive.Browser.PuppeteerCommunicator.GetCurrentTargetId ( )

Gets the CDP target ID of the active tab in the active window.

Returns
The target ID of the active tab, or null if there is no active window or active tab.

Definition at line 8686 of file PuppeteerCommunicator.cs.

◆ GetCurrentUrl()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetCurrentUrl ( string sessionId = null)

Gets the URL of the currently active page/frame by evaluating window.location.href.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the current page URL.
string url = await communicator.GetCurrentUrl();

Definition at line 5011 of file PuppeteerCommunicator.cs.

◆ GetCurrentWindow()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.GetCurrentWindow ( string sessionId = null)

Gets the browser window id associated with the current target via Browser.getWindowForTarget.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the window id of the current target.

Definition at line 5033 of file PuppeteerCommunicator.cs.

◆ GetCurrentWindowIndex()

int GenerallyPositive.Browser.PuppeteerCommunicator.GetCurrentWindowIndex ( string targetId)

Finds the index of the window whose tab queue contains the given target ID.

Parameters
targetIdThe CDP target ID to search for.
Returns
The zero-based index of the window containing the target, or -1 if not found.

Definition at line 8869 of file PuppeteerCommunicator.cs.

◆ GetCurrentWindowTargetId()

string GenerallyPositive.Browser.PuppeteerCommunicator.GetCurrentWindowTargetId ( )

Gets the browser context ID (window ID) of the active window.

Returns
The browser context ID of the active window.

Definition at line 8701 of file PuppeteerCommunicator.cs.

◆ GetDomAttributes()

async Task< Dictionary< string, object > > GenerallyPositive.Browser.PuppeteerCommunicator.GetDomAttributes ( int backendNodeId,
string sessionId = null )

Retrieves all DOM attributes (name/value pairs) of the element identified by the given backend node id, via DOM.getAttributes.

Parameters
backendNodeIdThe CDP backend node id of the element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to a dictionary of attribute names and values, or null on failure.

Definition at line 4585 of file PuppeteerCommunicator.cs.

◆ GetDomProperties()

async Task< Dictionary< string, object > > GenerallyPositive.Browser.PuppeteerCommunicator.GetDomProperties ( int backendNodeId,
string sessionId = null )

Retrieves DOM node info and JavaScript-side own properties of the element identified by the given backend node id, via DOM.describeNode and Runtime.getProperties.

Parameters
backendNodeIdThe CDP backend node id of the element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to a dictionary combining node attributes and own JavaScript property values, or null on failure.

Definition at line 4627 of file PuppeteerCommunicator.cs.

◆ GetEffectiveSessionId()

string GenerallyPositive.Browser.PuppeteerCommunicator.GetEffectiveSessionId ( )

Gets the session ID that should be used for the current operation, preferring the current iframe session (if inside an iframe) and otherwise falling back to the active tab's session.

Returns
The effective session ID to use for CDP commands.

Definition at line 8604 of file PuppeteerCommunicator.cs.

◆ GetElementAttributeHash()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.GetElementAttributeHash ( string elementId,
string sessionId = null )

Retrieves a JSON representation of all attributes of the element with the given DOM id.

Parameters
elementIdThe HTML "id" attribute value of the target element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the raw response from the Runtime.evaluate command, containing the element's attributes as a JSON string.

Definition at line 5082 of file PuppeteerCommunicator.cs.

◆ GetObjectIdFromBackendNodeId()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetObjectIdFromBackendNodeId ( int backendNodeId,
string sessionId = null,
long? contextId = null )

Resolves a backendNodeId to a RemoteObject objectId in the correct session and context (main page or iframe).

Definition at line 8484 of file PuppeteerCommunicator.cs.

◆ GetPageSource()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetPageSource ( string sessionId = null)

Retrieves the page's document source as raw HTML/XML text, by fetching the root document and its outer HTML via DOM.getDocument and DOM.getOuterHTML. The source is returned raw; normalization (unescaping and stripping Chrome's XML-viewer wrapper) is applied uniformly for all engines in Browser.GetPageSource.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the page source as a string, or an empty string if it could not be retrieved.
string html = await communicator.GetPageSource();

Definition at line 5106 of file PuppeteerCommunicator.cs.

◆ GetParentNode()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.GetParentNode ( string elementId,
string sessionId = null )

Retrieves the parent node of the element with the given DOM id.

Parameters
elementIdThe HTML "id" attribute value of the target element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the raw response from the Runtime.evaluate command, representing the parent node.

Definition at line 5219 of file PuppeteerCommunicator.cs.

◆ GetReadyStatus()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetReadyStatus ( string sessionId,
string sessionToken )

Gets the current document.readyState of the page, logging the status (and suppressing repeated identical messages within the same session token).

Parameters
sessionIdCDP session id; the effective session is used if null.
sessionTokenA token identifying the current logical session; when it changes, error/log state is reset.
Returns
Task that resolves to the document's ready state (e.g. "loading", "interactive", "complete").

Definition at line 5237 of file PuppeteerCommunicator.cs.

◆ GetShadowRoot()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.GetShadowRoot ( string css,
string sessionId = null )

Locates an element by CSS selector and retrieves a description of its node, including any shadow root, via DOM.describeNode.

Parameters
cssThe CSS selector used to locate the element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the raw response from the DOM.describeNode command.

Definition at line 5285 of file PuppeteerCommunicator.cs.

◆ GetStorage()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetStorage ( string storageType,
string sessionId,
string domain = null,
string storeName = null,
string path = null,
string key = null )

written by chatgpt Retrieves browser storage items as raw JSON text. Supports hierarchical wildcards: domain -> storeName -> path -> key.

Wildcard rules (null or empty parameters):

  • domain = null : list all domains
  • storeName = null : list object stores (IndexedDB)
  • path = null : list paths (cookies)
  • key = null : list keys at current level
  • key != null : retrieve value

Returned data is always raw JSON text; consumers must parse as needed.

Parameters
storageTypeStorage type: "cookie", "localStorage", "sessionStorage", "indexeddb", "cache"
sessionIdCDP session id; current session used if null
domainDomain/origin; null acts as wildcard
storeNameOptional object store name (IndexedDB)
pathOptional path (cookies)
keyOptional key; null acts as wildcard
Returns
Raw JSON string representing requested items or identifiers

Definition at line 5315 of file PuppeteerCommunicator.cs.

◆ GetTargetTabIdByUrl()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetTargetTabIdByUrl ( string url,
string sessionId = null )

Searches for an open tab whose CDP target URL contains url , checking the tabs of the currently active window first and then all other windows, querying Target.getTargetInfo for each tab (with both the raw and URL-decoded forms of the URL compared for the active window's tabs).

Parameters
urlThe URL (or substring of it) to search for; normalized via GPAL.MagicHelper.GetFullUrl. If empty/whitespace, the current target ID is returned instead.
sessionIdThe CDP session used to resolve the effective session if needed; if null, the effective session ID is resolved automatically.
Returns
A task that resolves to the CDP target ID of the matching tab, the current target ID if url was empty, or null if no match is found.
string tabId = await communicator.GetTargetTabIdByUrl("https://example.com/page2");

Definition at line 1917 of file PuppeteerCommunicator.cs.

◆ GetTargetWindowIdByUrl()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetTargetWindowIdByUrl ( string url,
string sessionId = null )

Searches every tracked window and tab for one whose underlying CDP target URL contains url , querying Target.getTargetInfo for each tab in turn, and returns the browser context ID of the containing window.

Parameters
urlThe URL (or substring of it) to search for among open tabs; normalized via GPAL.MagicHelper.GetFullUrl.
sessionIdUnused; reserved for future use.
Returns
A task that resolves to the browser context ID (window ID) of the window containing a matching tab, or null if no match is found.
string windowId = await communicator.GetTargetWindowIdByUrl("https://example.com/dashboard");

Definition at line 1876 of file PuppeteerCommunicator.cs.

◆ GetUserAgent()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetUserAgent ( string sessionId = null)

Gets the browser's user agent string by evaluating navigator.userAgent.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the current user agent string.

Definition at line 5528 of file PuppeteerCommunicator.cs.

◆ GetWindowRectangle()

async Task< System.Drawing.Rectangle > GenerallyPositive.Browser.PuppeteerCommunicator.GetWindowRectangle ( string sessionId = null)

Where this browser's window is and how big it is, in screen coordinates, asked of the browser itself rather than of the page. Browser.getWindowBounds answers with the whole window including its chrome, so it needs no JavaScript and works on a page that is still loading.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the window rectangle in screen coordinates.

Definition at line 5053 of file PuppeteerCommunicator.cs.

◆ GetXPathForElement()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetXPathForElement ( int backendNodeId,
bool optimized = true,
string sessionId = null )

Generates an XPath expression that identifies the element with the given backend node id.

Parameters
backendNodeIdThe CDP backend node id of the element.
optimizedWhether to prefer a shorter, optimized path (e.g. using the element's id) when possible.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the generated XPath expression, or an empty string if it could not be determined.

Definition at line 2740 of file PuppeteerCommunicator.cs.

◆ GetXPathOrCssForElement()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GetXPathOrCssForElement ( int backendNodeId,
string jsFunc,
bool optimized,
string sessionId )

Shared helper used by GetCssForElement and GetXPathForElement that resolves the element with the given backend node id to a remote object and invokes the supplied JavaScript function on it to compute a selector or path string.

Parameters
backendNodeIdThe CDP backend node id of the element to resolve.
jsFuncA JavaScript function declaration that takes (node, optimized) and returns the selector/path string.
optimizedWhether the JavaScript function should prefer a shorter, optimized result.
sessionIdCDP session id to use for the resolve and evaluate commands.
Returns
Task that resolves to the computed selector/path string, or an empty string on failure.

Definition at line 2847 of file PuppeteerCommunicator.cs.

◆ GoTo()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.GoTo ( string url,
string sessionId = null )

Navigates the current page/tab to the given URL.

Parameters
urlThe URL to navigate to.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if navigation succeeded, otherwise false.
await communicator.GoTo("https://example.com");

Definition at line 5553 of file PuppeteerCommunicator.cs.

◆ GoToTab()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GoToTab ( object tabIdOrUrlOrIndex,
string sessionId = null )

Switches the active tab to the one identified by the given index, target id, or URL.

Parameters
tabIdOrUrlOrIndexAn int tab index within the active window, or a string targetId or URL identifying the tab.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the targetId of the activated tab, or null if no matching tab was found.

Definition at line 5566 of file PuppeteerCommunicator.cs.

◆ GoToWindow()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.GoToWindow ( object tabIdOrUrl,
string sessionId = null )

Switches the active tab/window to the one identified by a tab index or page URL, activating the corresponding CDP target and updating the active window/tab indices.

Parameters
tabIdOrUrlEither an int index into the current tab queue, or a string URL to search for among open tabs.
sessionIdSession ID used when looking up the target by URL, or null to use the effective session.
Returns
A Task that resolves to the targetId of the activated tab, or null if no matching target was found.

Definition at line 8230 of file PuppeteerCommunicator.cs.

◆ HideElement()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.HideElement ( int backendNodeId,
string sessionId = null )

Hides the element identified by the given backend node id by setting its inline style to "display: none".

Parameters
backendNodeIdThe CDP backend node id of the element to hide.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the result of setting the element's "style" attribute.

Definition at line 5660 of file PuppeteerCommunicator.cs.

◆ Hover()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.Hover ( int backendNodeId,
string sessionId = null )

Moves the mouse pointer to a random point within the element identified by the given backend node id, dispatching an Input.dispatchMouseEvent "mouseMoved" event.

Parameters
backendNodeIdThe CDP backend node id of the element to hover over.
sessionIdCDP session id; the effective session is used if null.

Definition at line 5672 of file PuppeteerCommunicator.cs.

◆ InjectScript()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.InjectScript ( string scriptToInject,
string sessionId = null )

Registers a script via EnableFetchScriptInjection and tracks its CDP identifier so it can later be removed by ClearInjectedScripts.

Definition at line 1026 of file PuppeteerCommunicator.cs.

◆ IsClickable()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.IsClickable ( string elementId,
string sessionId = null )

Determines whether the element with the given DOM id is clickable, using the browser's checkVisibility() API.

Parameters
elementIdThe HTML "id" attribute value of the target element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the element is clickable/visible, otherwise false.
bool clickable = await communicator.IsClickable("submitButton");

Definition at line 5692 of file PuppeteerCommunicator.cs.

◆ IsDisplayed()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.IsDisplayed ( string elementId,
string sessionId = null )

Determines whether the element with the given DOM id is displayed, by checking that its offsetParent is not null.

Parameters
elementIdThe HTML "id" attribute value of the target element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the element is displayed, otherwise false.
bool visible = await communicator.IsDisplayed("statusBanner");

Definition at line 5719 of file PuppeteerCommunicator.cs.

◆ IsEnabled()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.IsEnabled ( string elementId,
string sessionId = null )

Determines whether the element with the given DOM id is enabled, by checking that its disabled property is false.

Parameters
elementIdThe HTML "id" attribute value of the target element.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the element is enabled, otherwise false.
bool enabled = await communicator.IsEnabled("submitButton");

Definition at line 5742 of file PuppeteerCommunicator.cs.

◆ IsEndOfPage()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.IsEndOfPage ( string sessionId = null)

Determines whether the page (or its nearest scrollable element) is scrolled to its end, taking into account the document's overflow style.

Parameters
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to true if the page/element is scrolled to the end, or true if detection failed (fail-forward).

Definition at line 5760 of file PuppeteerCommunicator.cs.

◆ IsVisibleInViewport()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.IsVisibleInViewport ( dynamic elemsOrBackendNodeId,
string sessionId = null )

Definition at line 5859 of file PuppeteerCommunicator.cs.

◆ LeftClick()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.LeftClick ( string elementId,
string sessionId = null )

Performs a left mouse click on the element(s) matching the given selector. Scrolls each matching element into view before clicking. Implementation for the "left-click" workflow action.

Parameters
elementIdCSS selector (or element identifier) used to locate the target element(s).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous click operation.
await LeftClick("#submit-button");
async Task LeftClick(string elementId, string sessionId=null)
Performs a left mouse click on the element(s) matching the given selector. Scrolls each matching elem...

Definition at line 6215 of file PuppeteerCommunicator.cs.

◆ LeftClickAndDownload()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.LeftClickAndDownload ( List< GPALElement > elems,
string downloadPath,
int modifiers,
string sessionId,
List< dynamic > responses )

Performs a left click on each element in elems to trigger a file download (headless mode). Sets the browser-level download behavior to the directory containing downloadPath before clicking. The actual filename cannot be controlled here, so a download watcher is required to detect the resulting file. Implementation for the "left-click-download" workflow action. Headless only.

Parameters
elemsElements to click (typically a download link or button).
downloadPathTarget file path; only its directory is used to configure the download location.
modifiersKeyboard modifier flags applied to the click (e.g. Ctrl/Shift).
sessionIdCDP session ID; falls back to the current effective session if null.
responsesList collecting the raw CDP responses from each click.
Returns
Task representing the asynchronous click-and-download operation.

Definition at line 6275 of file PuppeteerCommunicator.cs.

◆ LeftClickAndUpload()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.LeftClickAndUpload ( List< GPALElement > elems,
object uploadFiles,
int modifiers,
string sessionId,
List< dynamic > responses )

Attaches one or more files to file input element(s) using CDP. Supports single file path (string) or multiple paths (List<string> / IEnumerable<string>). Accumulates files across calls by tracking attached paths per session/input and re-attaching the full list each time. Uses DOM.setFileInputFiles to set files directly (headless-friendly, no dialog). Dispatches change event after attachment to trigger page/widget processing.

Parameters
elemsList of GPALElement instances representing the file input(s). Usually one, but supports multiple.
uploadFilesFile path(s) to attach.
  • string: single file path (e.g. "C:\temp\report.pdf") - IEnumerable&lt;string&gt; or List&lt;string&gt;: multiple file paths (e.g. new[] { @"C:\file1.pdf", @"C:\file2.jpg" }) </param> <param name="modifiers">Keyboard modifiers (not used in current implementation)</param> <param name="sessionId">CDP session ID (optional; falls back to current)</param> <param name="responses">Optional list to collect status/info (e.g. for logging or fluent chaining)</param> <returns>Task (async operation)</returns> <example> Single file: @code{cs} await LeftClickAndUpload(elems, @"C:\temp\doc.pdf", 0, sessionId, responses); @endcode Multiple files (additive across calls): @code{cs} var files = new List&lt;string&gt; { @"C:\doc1.pdf" }; await LeftClickAndUpload(elems, files, 0, sessionId, responses); files.Add(@"C:\photo.jpg"); await LeftClickAndUpload(elems, files, 0, sessionId, responses); // now attaches both @endcode Mixed: @code{cs} await LeftClickAndUpload(elems, @"C:\invoice.docx", 0, sessionId, responses); // single await LeftClickAndUpload(elems, new[] { @"C:\old1.pdf", @"C:\old2.pdf" }, 0, sessionId, responses); // full list

Definition at line 6333 of file PuppeteerCommunicator.cs.

◆ LeftClickByCss()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.LeftClickByCss ( string selector,
string sessionId = null )

Finds all elements matching the given CSS selector and performs a left click on each of them.

Parameters
selectorA CSS selector identifying the element(s) to click.
sessionIdCDP session id; the effective session is used if null.

Definition at line 2919 of file PuppeteerCommunicator.cs.

◆ LeftDoubleClick()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.LeftDoubleClick ( string elementId,
string sessionId = null )

Performs a left mouse double-click on the element(s) matching the given selector. Scrolls each matching element into view before double-clicking. Implementation for the "left-double-click" workflow action.

Parameters
elementIdCSS selector (or element identifier) used to locate the target element(s).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous double-click operation.

Definition at line 6431 of file PuppeteerCommunicator.cs.

◆ Maximize()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.Maximize ( string sessionId = null)

Maximizes the browser window so it fills the primary screen. Implementation for the "maximize" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to true once the window bounds have been updated.

Definition at line 6452 of file PuppeteerCommunicator.cs.

◆ MiddleClick()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.MiddleClick ( string elementId,
string sessionId = null )

Performs a middle mouse click on the element(s) matching the given selector. Scrolls each matching element into view before clicking. Implementation for the "middle-click" workflow action.

Parameters
elementIdCSS selector (or element identifier) used to locate the target element(s).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous click operation.
await MiddleClick("a.result-link");
async Task MiddleClick(string elementId, string sessionId=null)
Performs a middle mouse click on the element(s) matching the given selector. Scrolls each matching el...

Definition at line 7374 of file PuppeteerCommunicator.cs.

◆ Minimize()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.Minimize ( string sessionId = null)

Minimizes the browser window. Implementation for the "minimize" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to true once the window state has been set to minimized.

Definition at line 6475 of file PuppeteerCommunicator.cs.

◆ MoveTo() [1/3]

async Task GenerallyPositive.Browser.PuppeteerCommunicator.MoveTo ( int backendNodeId,
string sessionId = null )

Moves the mouse pointer to a randomized point within the element identified by backendNodeId . Implementation for the "move-to" workflow action.

Parameters
backendNodeIdCDP backend node ID of the target element.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous mouse move operation.

Definition at line 6546 of file PuppeteerCommunicator.cs.

◆ MoveTo() [2/3]

async Task GenerallyPositive.Browser.PuppeteerCommunicator.MoveTo ( int x,
int y,
string sessionId = null )

Moves the mouse pointer to a viewport coordinate rather than to an element, for targets that have no DOM handle at all - an image match being the case that needs it. This is a real browser level input event, so unlike a dispatched mouseover it does update the renderer's CSS :hover state.

Parameters
xViewport x coordinate, in CSS pixels.
yViewport y coordinate, in CSS pixels.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous mouse move operation.

Definition at line 6629 of file PuppeteerCommunicator.cs.

◆ MoveTo() [3/3]

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.MoveTo ( List< GPALElement > elems,
string sessionId,
List< dynamic > responses )

Moves the mouse pointer to a randomized point within each given element's bounding box (clicking dead-center for anchor/"A" elements), scrolling each element into view first. Used as a humanization step before interacting with elements.

Parameters
elemsElements to move the mouse over.
sessionIdCDP session ID used for the mouse move commands.
responsesList collecting the raw CDP responses from each mouse move.
Returns
Task that resolves to true if all moves succeeded, or false if any element raised an exception.

Definition at line 6497 of file PuppeteerCommunicator.cs.

◆ NavigateToUrl()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.NavigateToUrl ( string url,
string sessionId )

Definition at line 3076 of file PuppeteerCommunicator.cs.

◆ NewTab()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.NewTab ( GPALUrl url = null,
string sessionId = null )

Opens a new background tab in the currently active window and navigates it to the given URL. Resolves the URL via the magic helper, honors robots.txt restrictions when configured, and registers the new target/tab in the active window's tab queue. Implementation for the "new-tab" workflow action.

Parameters
urlURL to open in the new tab; defaults to a blank GPALUrl if null.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to the new tab's target ID, or null if no active window was found.
string newTargetId = await NewTab(new GPALUrl("https://example.com"));
Represents a URL with optional pre-navigation storage cleanup / inspection actions....
Definition GPALUrl.cs:53
async Task< string > NewTab(GPALUrl url=null, string sessionId=null)
Opens a new background tab in the currently active window and navigates it to the given URL....

Definition at line 6650 of file PuppeteerCommunicator.cs.

◆ NextTab()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.NextTab ( string currentTargetId)

Switches the active tab in the current window to the next tab in the tab queue (wrapping around). Before switching, polls CDP for all targets to discover and register any tabs not yet in the queue. Implementation for the "next-tab" workflow action.

Parameters
currentTargetIdTarget ID of the currently active tab, used to determine the starting position.
Returns
Task that resolves to the target ID of the newly activated next tab, or null if there is no active window or no tabs.

Definition at line 6729 of file PuppeteerCommunicator.cs.

◆ NextWindow()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.NextWindow ( string currentTargetId)

Switches the active browser window/context to the next window in the window queue (wrapping around), activating that window's currently active tab and re-attaching the CDP session if needed. Implementation for the "next-window" workflow action.

Parameters
currentTargetIdTarget ID of the currently active tab, used to determine which window is currently active.
Returns
Task that resolves to the target ID of the active tab in the next window, or null if there are no windows or no tabs in the next window.

Definition at line 6839 of file PuppeteerCommunicator.cs.

◆ Normal()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.Normal ( string sessionId = null)

Restores the browser window to its normal (non-maximized, non-minimized) state. Implementation for the "normal" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to true once the window state has been set to normal.

Definition at line 6911 of file PuppeteerCommunicator.cs.

◆ OpenWindow()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.OpenWindow ( string url = "https://google.com",
string sessionId = null )

Opens a brand new browser window (its own browser context) navigated to the given URL, activates and attaches to it via CDP, and registers it as the new active window with its own tab queue. Implementation for the "open-window" workflow action.

Parameters
urlURL to load in the new window; defaults to "https://google.com".
sessionIdCDP session ID used for the create/attach commands; falls back to the current effective session if null.
Returns
Task that resolves to the target ID of the newly created window's tab.

Definition at line 6934 of file PuppeteerCommunicator.cs.

◆ OverrideReferrer()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.OverrideReferrer ( string url,
string sessionId = null )

Overrides the HTTP Referer header sent with subsequent requests to the given URL. Implementation for the "override-referrer" workflow action.

Parameters
urlURL value to use as the Referer header.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous header override operation.

Definition at line 6980 of file PuppeteerCommunicator.cs.

◆ PageDown()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.PageDown ( int pagesToScroll = 1,
string sessionId = null )

Scrolls the page down by one or more page heights. Implementation for the "page-down" workflow action.

Parameters
pagesToScrollNumber of page-height increments to scroll down (default 1).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous scroll operation.

Definition at line 7009 of file PuppeteerCommunicator.cs.

◆ PageEnd()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.PageEnd ( string sessionId = null)

Scrolls to the very bottom of the page. Implementation for the "page-end" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous scroll operation.

Definition at line 7025 of file PuppeteerCommunicator.cs.

◆ PageTop()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.PageTop ( string sessionId = null)

Scrolls to the very top of the page. Implementation for the "page-top" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous scroll operation.

Definition at line 7038 of file PuppeteerCommunicator.cs.

◆ PageUp()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.PageUp ( int pagesToScroll = 1,
string sessionId = null )

Scrolls the page up by one or more page heights. Implementation for the "page-up" workflow action.

Parameters
pagesToScrollNumber of page-height increments to scroll up (default 1).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous scroll operation.

Definition at line 7052 of file PuppeteerCommunicator.cs.

◆ PressModifierKey()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.PressModifierKey ( int modifierKeys,
string sessionId = null )

Dispatches a key-down event for the given modifier key(s) without a corresponding key-up, leaving the modifier(s) "held" for subsequent input events. Implementation for the "press-modifier-key" workflow action.

Parameters
modifierKeysBitmask of CDP modifier flags to press (e.g. Alt, Ctrl, Meta, Shift).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous key-down operation.

Definition at line 7070 of file PuppeteerCommunicator.cs.

◆ PreviousTab()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.PreviousTab ( string currentTargetId)

Switches the active tab in the current window to the previous tab in the tab queue (wrapping around). Before switching, polls CDP for all targets to discover and register any tabs not yet in the queue, updates the window's active tab index, and re-attaches the CDP session if needed. Implementation for the "previous-tab" workflow action.

Parameters
currentTargetIdTarget ID of the currently active tab, used to determine the starting position.
Returns
Task that resolves to the target ID of the newly activated previous tab, or null if there is no active window or no tabs.

Definition at line 7085 of file PuppeteerCommunicator.cs.

◆ PreviousWindow()

async Task< string > GenerallyPositive.Browser.PuppeteerCommunicator.PreviousWindow ( string currentTargetId)

Switches the active browser window/context to the previous window in the window queue (wrapping around), activating that window's currently active tab and re-attaching the CDP session if needed. Implementation for the "previous-window" workflow action.

Parameters
currentTargetIdTarget ID of the currently active tab, used to determine which window is currently active.
Returns
Task that resolves to the target ID of the active tab in the previous window, or null if there are no windows or no tabs in the previous window.

Definition at line 7199 of file PuppeteerCommunicator.cs.

◆ QueryByCss()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.QueryByCss ( string selector,
string sessionId = null )

Queries the document for the first element matching the given CSS selector.

Parameters
selectorA CSS selector to match against the document.
sessionIdCDP session id; the effective session is used if null.
Returns
Task that resolves to the matching DOM node id, or 0 if no element was found.

Definition at line 2033 of file PuppeteerCommunicator.cs.

◆ QuerySelector()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.QuerySelector ( string css,
string sessionId = null )

Finds the first element matching the given CSS selector. Implementation for the "query-selector" workflow action.

Parameters
cssCSS selector to query for.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to the matching element (CDP result), or null/empty if not found.

Definition at line 7271 of file PuppeteerCommunicator.cs.

◆ QuerySelectors()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.QuerySelectors ( string css,
string sessionId = null )

Finds all elements matching the given CSS selector, starting from the document root. Implementation for the "query-selectors" workflow action.

Parameters
cssCSS selector to query for.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to the raw CDP result containing the matching node IDs.

Definition at line 7302 of file PuppeteerCommunicator.cs.

◆ Refresh()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.Refresh ( string sessionId = null)

Reloads the current page. Implementation for the "refresh" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous reload operation.

Definition at line 7318 of file PuppeteerCommunicator.cs.

◆ ReleaseModifierKey()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.ReleaseModifierKey ( int modifierKeys,
string sessionId = null )

Dispatches a key-up event for the given modifier key(s), releasing modifier(s) previously held via PressModifierKey. Implementation for the "release-modifier-key" workflow action.

Parameters
modifierKeysBitmask of CDP modifier flags to release (e.g. Alt, Ctrl, Meta, Shift).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous key-up operation.

Definition at line 7333 of file PuppeteerCommunicator.cs.

◆ RemoveInjectedScript()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.RemoveInjectedScript ( string identifier,
string sessionId = null )

Removes a script previously registered via EnableFetchScriptInjection, using Page.removeScriptToEvaluateOnNewDocument.

Parameters
identifierThe CDP script identifier returned by EnableFetchScriptInjection.
sessionIdThe CDP session (or target ID) to remove the script from; if null, the effective session ID is resolved automatically.

Definition at line 989 of file PuppeteerCommunicator.cs.

◆ Restore()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.Restore ( string sessionId = null)

Restores the browser window to its normal (non-maximized, non-minimized) window state. Implementation for the "restore" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to true once the window state has been set to normal.

Definition at line 7346 of file PuppeteerCommunicator.cs.

◆ RestoreDownloadBehavior()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.RestoreDownloadBehavior ( string sessionId = null)

Hands the download directory back to the browser, so a profile the workflow borrowed is not left saving everything the user downloads afterwards into the workflow's folder.
CDP has no way to read the directory that was in force, but "default" means the browser's own setting, whatever that is, which is exactly where it should end up.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null
Returns
Task representing the asynchronous call

Definition at line 6254 of file PuppeteerCommunicator.cs.

◆ RightClick()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.RightClick ( string elementId,
string sessionId = null )

Performs a right mouse click on the element(s) matching the given selector. Scrolls each matching element into view before clicking. Implementation for the "right-click" workflow action.

Parameters
elementIdCSS selector (or element identifier) used to locate the target element(s).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous click operation.
await RightClick("#context-menu-target");
async Task RightClick(string elementId, string sessionId=null)
Performs a right mouse click on the element(s) matching the given selector. Scrolls each matching ele...

Definition at line 7401 of file PuppeteerCommunicator.cs.

◆ RightClickAndDownload()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.RightClickAndDownload ( string elementId,
string savePath,
string sessionId = null )

Configures the page-level download behavior to save to savePath , then performs a right click on the element(s) matching the given selector to trigger a "Save link as" style download. Implementation for the "right-click-download" workflow action.

Parameters
elementIdCSS selector (or element identifier) used to locate the target element(s).
savePathDirectory path where downloads triggered by this click should be saved.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous right-click-and-download operation.

Definition at line 7424 of file PuppeteerCommunicator.cs.

◆ ScrollElement()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.ScrollElement ( string elementId,
int hPixels,
int vPixels,
string sessionId = null )

Scrolls the element with the given DOM id by the specified number of pixels horizontally and vertically, using Element.scrollBy. Implementation for the "scroll-element" workflow action.

Parameters
elementIdDOM id of the element to scroll (used directly in document.getElementById).
hPixelsHorizontal pixels to scroll by.
vPixelsVertical pixels to scroll by.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous scroll operation.

Definition at line 7441 of file PuppeteerCommunicator.cs.

◆ ScrollIntoView()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.ScrollIntoView ( GPALElement element,
string sessionId = null )

Scrolls the given element into the viewport, first attempting the native CDP DOM.scrollIntoViewIfNeeded command and falling back to a JavaScript Element.scrollIntoView call if the native command does not return a result. In headless mode, also forces a layout reflow before and a brief delay after scrolling, and injects a one-time stylesheet disabling overscroll bounce so elements don't shift after scrolling. Implementation for the "scroll-into-view" workflow action.

Parameters
elementElement to scroll into view.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to true if the scroll completed (or was attempted) without error, or false if an exception occurred.
await ScrollIntoView(element, sessionId);
async Task< bool > ScrollIntoView(GPALElement element, string sessionId=null)
Scrolls the given element into the viewport, first attempting the native CDP DOM.scrollIntoViewIfNeed...

Definition at line 7468 of file PuppeteerCommunicator.cs.

◆ ScrollPageAsync()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.ScrollPageAsync ( string direction,
int pagesToScroll,
string s )

Scrolls the page up or down by one or more "pages" (the viewport height), trying window.scrollBy first and falling back to scrolling the nearest scrollable element (and finally a Page Up/Down key press) for single-page applications where the document itself does not scroll.

Parameters
directionThe scroll direction, either "up" or "down".
pagesToScrollThe number of viewport-height pages to scroll.
sThe CDP session ID to use.
Returns
A Task that resolves to true if at least one page of scrolling succeeded; false otherwise.

Definition at line 8978 of file PuppeteerCommunicator.cs.

◆ ScrollToPositionAsync()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.ScrollToPositionAsync ( string position,
string s )

Scrolls the page to the very top or very bottom, trying window.scrollTo first, then the nearest scrollable element's scrollTo, and finally a Home/End key press as a last resort.

Parameters
positionThe target scroll position, either "top" or "end".
sThe CDP session ID to use.
Returns
A Task that resolves to true if the scroll position changed; false otherwise.

Definition at line 9147 of file PuppeteerCommunicator.cs.

◆ ScrollWindow()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.ScrollWindow ( int hPixels,
int vPixels,
string sessionId = null )

Scrolls the whole window/viewport by the specified number of pixels horizontally and vertically, then waits briefly to allow headless rendering to settle. Implementation for the "scroll-window" workflow action.

Parameters
hPixelsHorizontal pixels to scroll by.
vPixelsVertical pixels to scroll by.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous scroll operation.

Definition at line 7657 of file PuppeteerCommunicator.cs.

◆ ScrollWindowByPixelsAsync()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.ScrollWindowByPixelsAsync ( int hPixels,
int vPixels,
string sessionId )

Scrolls the page or the nearest scrollable element by the given relative pixel offsets, trying window.scrollBy first, then an element's scrollBy, and finally falling back to Input.synthesizeScrollGesture (a touch-based scroll gesture).

Parameters
hPixelsThe horizontal scroll distance in pixels (positive scrolls right).
vPixelsThe vertical scroll distance in pixels (positive scrolls down).
sessionIdThe CDP session ID to use.
Returns
A Task that resolves to true if the scroll position changed; false otherwise.

Definition at line 9283 of file PuppeteerCommunicator.cs.

◆ SelectByIndex()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.SelectByIndex ( string ElementHandle,
int index,
string sessionId = null )

Selects an option in a <select> element by its zero-based index and dispatches "input" and "change" events so that page scripts react to the change.

Parameters
ElementHandleThe CDP remote object ID of the select element to update.
indexThe zero-based index of the option to select.
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to true if the selected index actually changed; false if the index is out of range or unchanged.

Definition at line 9426 of file PuppeteerCommunicator.cs.

◆ SelectByValue()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.SelectByValue ( string ElementHandle,
string value,
string sessionId = null )

Sets the value of an input or select element to the given value and dispatches "input" and "change" events so that page scripts react to the change.

Parameters
ElementHandleThe CDP remote object ID of the element to update.
valueThe value to assign to the element.
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to true if the element's value actually changed; false otherwise.

Definition at line 9395 of file PuppeteerCommunicator.cs.

◆ SendCommand< TParameters >()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.SendCommand< TParameters > ( DevToolsMethods method,
TParameters parameters,
string sessionId,
int retries = 3,
bool doNotGetSemaphore = false,
int timeoutSeconds = 0 )

Definition at line 661 of file PuppeteerCommunicator.cs.

◆ SendKey()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.SendKey ( string key,
string code,
int vkCode,
string sessionId = null )

Dispatches a full key press sequence (keydown, optional char, keyup) for the given key via CDP, using "\r" as the char payload for the Enter key so forms submit correctly, and the literal character for single-character keys. Implementation for the "send-key" workflow action.

Parameters
keyKey value (e.g. "Enter", "a", "ArrowDown") as used by the CDP key event.
codePhysical key code (e.g. "Enter", "KeyA", "ArrowDown") as used by the CDP key event.
vkCodeWindows virtual key code corresponding to the key.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to true if all key events were dispatched successfully, or false if an exception occurred.

Definition at line 7676 of file PuppeteerCommunicator.cs.

◆ SendString()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.SendString ( string text,
int delayMs = 0,
string sessionId = null )

Sends the given text at the current focus/cursor position. With delayMs equal to 0 (the default), the whole string is inserted atomically via CDP's Input.insertText. When delayMs is greater than 0, the text is dispatched character-by-character via DispatchTextCharByChar, sleeping delayMs milliseconds between characters. Implementation for the "send-string" workflow action (equivalent to "fill-in").

Parameters
textText to insert.
delayMsInter-character pacing delay in milliseconds. 0 sends the whole string atomically.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous text insertion operation.

Definition at line 7830 of file PuppeteerCommunicator.cs.

◆ SetAttribute()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.SetAttribute ( int backendNodeId,
string attribute,
string value,
string sessionId = null )

Sets the value of an HTML attribute on the element identified by backendNodeId . Implementation for the "set-attribute" workflow action.

Parameters
backendNodeIdCDP backend node ID of the target element.
attributeName of the attribute to set.
valueValue to assign to the attribute.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to the raw CDP result of the attribute-set command.

Definition at line 7892 of file PuppeteerCommunicator.cs.

◆ SetDownloadBehavior()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.SetDownloadBehavior ( string downloadPath,
string sessionId = null )

Accept downloads into downloadPath without asking where to put them.
Browser scoped rather than page scoped, so it holds for every tab opened afterwards, which is what a url fetched into a new tab depends on.
This has to be done over CDP because the Save dialog is a profile preference fixed when the browser launched, and MagicHelper.LaunchBrowser only writes that preference when it builds the profile itself. Hand it an existing profile and the preference is never applied.

Parameters
downloadPathDirectory downloads should land in
sessionIdCDP session ID; falls back to the current effective session if null
Returns
Task representing the asynchronous call

Definition at line 6239 of file PuppeteerCommunicator.cs.

◆ SetDownloadFilename()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.SetDownloadFilename ( string downloadPath,
string sessionId = null )

Configures the page-level download behavior so that future downloads are saved to the given path. Implementation for the "set-download-filename" workflow action.

Parameters
downloadPathDirectory path where downloads should be saved.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous configuration operation.

Definition at line 7908 of file PuppeteerCommunicator.cs.

◆ SetRange()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.SetRange ( string elementId,
string rangeValue,
string sessionId = null )

Sets the value of the element matching the given CSS selector and dispatches "input" and "change" events so the page reacts to the new value (e.g. for range/slider inputs). Implementation for the "set-range" workflow action.

Parameters
elementIdCSS selector identifying the target element.
rangeValueNew value to assign (inserted directly into the generated JavaScript expression).
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to the raw CDP result of the JavaScript evaluation.

Definition at line 7924 of file PuppeteerCommunicator.cs.

◆ SetStorage()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.SetStorage ( string storageType,
string sessionId,
string domain,
string key,
string data,
string storeName = null,
string path = null )

Sets a value in browser storage. Required parameters must be supplied. Returns "success" if write completed, null if failed.

Parameters
storageTypeStorage type: "cookie", "localStorage", "sessionStorage", "indexeddb", "cache"
sessionIdCDP session id; current session used if null
domainDomain/origin (required)
keyKey or cache name (required)
dataValue to store (required)
storeNameOptional object store (IndexedDB, required for IndexedDB)
pathOptional path (cookies, default "/")
Returns
"success" or null if failed

Definition at line 7962 of file PuppeteerCommunicator.cs.

◆ SetUserAgent()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.SetUserAgent ( string userAgent,
string sessionId = null )

Overrides the browser's user agent string (including navigator.userAgent) for subsequent requests. Implementation for the "set-useragent" workflow action.

Parameters
userAgentThe user agent string to use.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to the raw CDP result of the override operation.

Definition at line 6994 of file PuppeteerCommunicator.cs.

◆ SetValueFromElement()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.SetValueFromElement ( string srcCss,
string destCss,
string sessionId = null )

Copies the value from a source element into a destination element by setting destElement.value = srcElement.value via JavaScript evaluation, then dispatches "input" and "change" events on the destination so the page reacts to the new value. Implementation for the "set-value-from-element" workflow action.

Parameters
srcCssCSS selector identifying the source element whose value is read.
destCssCSS selector identifying the destination element whose value is set.
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task that resolves to the raw CDP result of the JavaScript evaluation.

Definition at line 8162 of file PuppeteerCommunicator.cs.

◆ StealthOverrideReferrer()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.StealthOverrideReferrer ( string sessionId = null)

Overrides the HTTP Referer header for subsequent requests to "https://www.google.com", used to make navigation appear as if it originated from a Google search. Implementation for the "stealth-override-referrer" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous header override operation.

Definition at line 8181 of file PuppeteerCommunicator.cs.

◆ StopCasting()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.StopCasting ( string sessionId)

Attempts to stop an active Cast session for the current sink. Note: there may be no reliable programmatic way to cleanly stop casting other than closing the tab or window.

Parameters
sessionIdCDP session id to send the stop-casting command on.
Returns
Task that resolves to true once the stop attempt has completed (regardless of whether casting actually stopped).
await communicator.StopCasting(sessionId);

Definition at line 3239 of file PuppeteerCommunicator.cs.

◆ SubmitForm()

async Task< dynamic > GenerallyPositive.Browser.PuppeteerCommunicator.SubmitForm ( string objectId,
string sessionId = null )

Submits the HTML form represented by the given remote object by invoking its submit() method.

Parameters
objectIdThe CDP remote object ID of the form element to submit.
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the raw CDP result of the function call.

Definition at line 8194 of file PuppeteerCommunicator.cs.

◆ SwitchToDefaultContent()

Task GenerallyPositive.Browser.PuppeteerCommunicator.SwitchToDefaultContent ( string sessionId = null)

Switches the active context back to the top-level page document, clearing any current iframe/shadow root context.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task representing the asynchronous operation.

Definition at line 8211 of file PuppeteerCommunicator.cs.

◆ SwitchToElement()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.SwitchToElement ( string elementSelector)

Resolves the shadow root of an element matching the given selector and stores its remote object id so that subsequent selector evaluations can query inside the shadow DOM.

Parameters
shadowHostSelectorA CSS or XPath selector identifying the shadow host element.

Scopes later selectors to inside the element matching elementSelector , by holding that element as the root everything is resolved against. Nothing goes over the wire beyond finding the element: there is no current element in CDP, so the scope is ours to keep.

This is not how a frame is entered. A frame needs its own execution context, which SwitchToFrame attaches to, and an iframe from another origin cannot be reached as a node at all.

Parameters
elementSelectorA CSS or XPath selector identifying the element to search inside.

Definition at line 2168 of file PuppeteerCommunicator.cs.

◆ SwitchToFrame()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.SwitchToFrame ( string frameSelector)

Resolves an iframe element matching the given selector and switches the current evaluation context into that iframe by attaching to its frame target (for cross-origin frames) and creating an isolated JavaScript execution world. Subsequent DOM/JS operations will operate inside the iframe until the context is reset.

Parameters
frameSelectorA CSS or XPath selector identifying the iframe element.

Definition at line 2073 of file PuppeteerCommunicator.cs.

◆ SwitchToShadowDom()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.SwitchToShadowDom ( string shadowHostSelector)

Definition at line 2187 of file PuppeteerCommunicator.cs.

◆ TopBrowser()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.TopBrowser ( string sessionId = null)

Brings the current page/tab to the front of the operating system's window stack. Implementation for the "top-browser" workflow action.

Parameters
sessionIdCDP session ID; falls back to the current effective session if null.
Returns
Task representing the asynchronous bring-to-front operation.

Definition at line 7942 of file PuppeteerCommunicator.cs.

◆ WaitForEvent()

async Task GenerallyPositive.Browser.PuppeteerCommunicator.WaitForEvent ( string eventName,
TimeSpan timeout )

Polls the internal CDP event queue until an event named eventName is dequeued or the specified timeout elapses, logging a warning if the timeout is reached without finding a match. Note that any non-matching events dequeued while waiting are discarded.

Parameters
eventNameThe CDP event name to wait for (e.g. "Network.loadingFinished").
timeoutThe maximum amount of time to wait for the event before giving up.
Returns
A task that completes when the matching event is found or the timeout expires.
await communicator.WaitForEvent("Network.loadingFinished", TimeSpan.FromSeconds(10));

Definition at line 1682 of file PuppeteerCommunicator.cs.

◆ WaitForLayoutReady()

async Task< bool > GenerallyPositive.Browser.PuppeteerCommunicator.WaitForLayoutReady ( GPALElement element,
string sessionId,
int maxWaitMs = 3000,
int pollIntervalMs = 150 )

Polls until the given element's layout has stabilized with non-zero dimensions, first using DOM.getBoxModel (re-resolving the element via EvaluateSelector if it has become detached), and falling back to a JavaScript getBoundingClientRect check if the box model is unavailable.

Parameters
elementThe element whose layout readiness should be checked; may be updated in place if it needs to be re-resolved.
sessionIdThe CDP session to query; if null, the effective session ID is resolved automatically.
maxWaitMsThe maximum total time, in milliseconds, to wait for the element to become laid out.
pollIntervalMsThe delay, in milliseconds, between polling attempts.
Returns
A task that resolves to true if the element's layout becomes ready (non-zero, visible dimensions) within the timeout; otherwise false.
bool ready = await communicator.WaitForLayoutReady(element, sessionId, maxWaitMs: 5000);
if (!ready)
{
// handle layout timeout
}

Definition at line 1714 of file PuppeteerCommunicator.cs.

◆ WindowInnerHeight()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowInnerHeight ( string sessionId = null)

Gets the height of the browser window's viewport (window.innerHeight), in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the viewport height in pixels.

Definition at line 8281 of file PuppeteerCommunicator.cs.

◆ WindowInnerWidth()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowInnerWidth ( string sessionId = null)

Gets the width of the browser window's viewport (window.innerWidth), in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the viewport width in pixels.

Definition at line 8299 of file PuppeteerCommunicator.cs.

◆ WindowOuterHeight()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowOuterHeight ( string sessionId = null)

Gets the outer height of the browser window (window.outerHeight), including browser chrome, in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the window's outer height in pixels.

Definition at line 8317 of file PuppeteerCommunicator.cs.

◆ WindowOuterWidth()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowOuterWidth ( string sessionId = null)

Gets the outer width of the browser window (window.outerWidth), including browser chrome, in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the window's outer width in pixels.

Definition at line 8335 of file PuppeteerCommunicator.cs.

◆ WindowPageOffsetX()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowPageOffsetX ( string sessionId = null)

Gets the horizontal scroll offset of the page (window.pageXOffset), in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the current horizontal scroll offset in pixels.

Definition at line 8385 of file PuppeteerCommunicator.cs.

◆ WindowPageOffsetY()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowPageOffsetY ( string sessionId = null)

Gets the vertical scroll offset of the page (window.pageYOffset), in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the current vertical scroll offset in pixels.

Definition at line 8403 of file PuppeteerCommunicator.cs.

◆ WindowScreenLeft()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowScreenLeft ( string sessionId = null)

Gets the horizontal position of the browser window relative to the screen (window.screenLeft), in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the window's left position on screen, in pixels.

Definition at line 8421 of file PuppeteerCommunicator.cs.

◆ WindowScreenTop()

async Task< int > GenerallyPositive.Browser.PuppeteerCommunicator.WindowScreenTop ( string sessionId = null)

Gets the vertical position of the browser window relative to the screen (window.screenTop), in pixels.

Parameters
sessionIdTarget session ID, or null to use the effective session.
Returns
A Task that resolves to the window's top position on screen, in pixels.

Definition at line 8439 of file PuppeteerCommunicator.cs.

Property Documentation

◆ CurrentSessions

ConcurrentQueue<KeyValuePair<string, string> > GenerallyPositive.Browser.PuppeteerCommunicator.CurrentSessions
get

Queue of (sessionId, targetId) pairs for tabs in the currently active window.

Definition at line 124 of file PuppeteerCommunicator.cs.

◆ CurrentTargetID

string GenerallyPositive.Browser.PuppeteerCommunicator.CurrentTargetID
get

The target id of the PuppeteerClient's currently selected tab/session.

Definition at line 135 of file PuppeteerCommunicator.cs.

◆ ServerResponseCode

int GenerallyPositive.Browser.PuppeteerCommunicator.ServerResponseCode
getset

server response code from last operation

Definition at line 72 of file PuppeteerCommunicator.cs.

◆ webSocketUrl

string GenerallyPositive.Browser.PuppeteerCommunicator.webSocketUrl
get

Definition at line 65 of file PuppeteerCommunicator.cs.


The documentation for this class was generated from the following file: