GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GenerallyPositive.Browser.MagicHelper Class Reference
Inheritance diagram for GenerallyPositive.Browser.MagicHelper:
GenerallyPositive.Browser.IMagicHelper

Public Member Functions

void Back ()
 Navigates browser history back browser.MagicHelper.Back();.
string CaptureVisibleTab ()
string CheckNetworkIdle (int? maxConnections=null, int? timeoutMs=null, int? pruneMs=null)
 Reports whether the network is idle.

Each parameter is optional and defaults to the browser setting: WithNetworkIdleMaxConnections, WithNetworkIdleTimeoutMs and WithNetworkIdlePruneMs. Called with no arguments it matches what GPAL checks after a navigation. bool idle = browser.MagicHelper.CheckNetworkIdle(5);.
TabTuple CloseTab (dynamic URLorTabId=null)
 Closes a tab by URL or tab ID TabTuple closed = browser.MagicHelper.CloseTab("https://example.com");.
bool DeleteStorage (WebsiteStorageType storageType, bool deleteAcrossOrigins=false, string domain=null, string path=null, string key=null, string storeName=null)
 Delete the type of storage type specified, if any parameter is missing, then that is a wildcard to delete all, from that domain and down or across domains if omitted.
string GetStorage (WebsiteStorageType storageType, string domain=null, string path=null, string key=null, string storeName=null)
 Get the type of storage type specified, if any parameter is missing, then that is a wildcard to get all, from that domain and down or across domains if omitted.
bool SetStorage (WebsiteStorageType storageType, string data, string domain=null, string path=null, string key=null, string storeName=null)
void Forward ()
 Navigates browser history forward browser.MagicHelper.Forward();.
void FullScreen ()
 Sets browser to full screen browser.MagicHelper.FullScreen();.
string Get (GPALUrl URL)
 Navigates to a URL string result = browser.MagicHelper.Get("https://example.com");.
string GetContentAndCss (string elementId)
 Gets content and CSS for a elementId string content = browser.MagicHelper.GetContentAndCss(elementId);.
Dictionary< string, object > GetCssAttributes (string elementId)
Dictionary< string, object > GetDomAttributes (string elementId)
Dictionary< string, object > GetDomProperties (string elementId)
string GetCurrentUrl ()
 Gets the current URL string url = browser.MagicHelper.GetCurrentUrl();.
string GetReadyStatus ()
 Gets the ready status NOTE: if no page is loaded, this will return null cause there is no content script. so it's "complete". string status = browser.MagicHelper.GetReadyStatus();.
GPALElement GetShadowRoot (string elementId)
 Gets the shadow root for an elementId GPALElement root = browser.MagicHelper.GetShadowRoot(elementId);.
TabTuple GoTo (GPALUrl URL)
 Navigates to a URL TabTuple tab = browser.MagicHelper.Goto("https://example.com");.
TabTuple GotoTab (dynamic URLorTabId)
 Navigates to a tab by URL or tab ID TabTuple tab = browser.MagicHelper.GotoTab("https://example.com");.
void SwitchToElement (string elementId)
 Switches context to an element browser.MagicHelper.InElement();NOTE: InFrame and InElement are identical in implementation.
void InFrame (string elementId)
 Switches context to iframe browser.MagicHelper.InFrame();NOTE: InFrame and InElement are identical in implementation.
void Minimize ()
 Minimizes the browser window browser.MagicHelper.Minimize();.
void Maximize ()
 Maximizes the browser window browser.MagicHelper.Maximize();.
void MoveTo (string elementId)
 Scrolls an element into view by ID browser.MagicHelper.ScrollIntoView("element123");.
void Normal ()
 Restores the browser window to normal browser.MagicHelper.Normal();.
TabTuple NewTab (GPALUrl URL=null)
 Opens a new tab with optional URL TabTuple tab = browser.MagicHelper.NewTab("https://example.com");.
TabTuple NextTab ()
 Switches to the next tab TabTuple tab = browser.MagicHelper.NextTab();.
int TabCount ()
 How many tabs the browser actually has open, which is not the same as how many GPAL opened. A tab can close itself, which is what a browser does with a tab whose first navigation turns into a download. int tabs = browser.MagicHelper.TabCount();.
WindowTuple NextWindow ()
 Switches to the next window WindowTuple window = browser.MagicHelper.NextWindow();.
void OverrideReferrer (string referrer)
 Overrides the referrer URL browser.MagicHelper.OverrideReferrer("https://google.com");.
void SetUserAgent (string userAgent)
 Overrides the browser's user agent string browser.MagicHelper.SetUserAgent("Mozilla/5.0 ...");.
void PageDown ()
 Scrolls the page down browser.MagicHelper.PageDown();.
void PageEnd ()
 Scrolls to the page end browser.MagicHelper.PageEnd();.
void PageTop ()
 Scrolls to the page top browser.MagicHelper.PageTop();.
void PageUp ()
 Scrolls the page up browser.MagicHelper.PageUp();.
void PressModifierKey (ModifierKeys modifierKeys)
 Press the specified modifier keys.
TabTuple PreviousTab ()
 Switches to the previous tab TabTuple tab = browser.MagicHelper.PreviousTab();.
WindowTuple PreviousWindow ()
 Switches to the previous window WindowTuple window = browser.MagicHelper.PreviousWindow();.
void Refresh ()
 Refreshes the current page browser.MagicHelper.Refresh();.
void ReleaseModifierKey (ModifierKeys modifierKeys)
 Press the specified modifier keys.
void Restore ()
 Restores the browser window browser.MagicHelper.Restore();.
void ScrollWindowHorizontal (int pixels)
 Scrolls the window horizontally by pixels browser.MagicHelper.ScrollWindowByHorizontal(100);.
void ScrollWindowVertical (int pixels)
 Scrolls the window vertically by pixels browser.MagicHelper.ScrollWindowByVertical(100);.
void SetGoogleReferrer ()
 Overrides referrer stealthily browser.MagicHelper.SetGoogleReferrer();.
void WithDownloadFile (string downloadPath)
 Names the file the next download should land under.
Only the leaf name is sent. The extension names a download through onDeterminingFilename, which takes a name relative to the browser's own download directory and rejects an absolute path outright, so the directory half of downloadPath would silently cost us the name as well. The file arrives in the browser's download directory and the download watcher moves it where it was asked to go. browser.MagicHelper.WithDownloadFile("c:\sdi\sample.pdf"); // the extension is sent sample.pdf.
int WindowScreenLeft ()
 Gets the window screen left position int left = browser.MagicHelper.WindowScreenLeft();.
int WindowScreenTop ()
 Gets the window screen top position int top = browser.MagicHelper.WindowScreenTop();.
void Focus (string elementId)
 Focuses an element by ID browser.MagicHelper.Focus("element123");.
void FireChangeEvent (string elementId)
 Fires a change event on an element by ID browser.MagicHelper.FireChangeEvent("element123");.
Rectangle GetWindowRectangle ()
 Returns the browser window inner/outer height/widge { y: window.innerHeight, x: window.width, height: window.outerHeight, width: window.outerWidth }.
void ScrollIntoView (string elementId)
 Scrolls an element into view by ID browser.MagicHelper.ScrollIntoView("element123");.
void ScrollElement (string elementId, int hPixels, int vPixels)
 Scrolls an element by horizontal and vertical pixels browser.MagicHelper.ScrollElement(100, 200);.
string GetElementAttributeHash (string elementId)
 Gets the attribute hash of an element string hash = browser.MagicHelper.GetElementAttributeHash();.
List< GPALElement > GetOptions (string elementId)
 Get select menu option items.
string GetPageSource ()
 Get the html source of the current page.
GPALElement GetParentNode (string elementId)
 Gets the parent node of an element by ID string parent = browser.MagicHelper.GetParentNode("element123");.
string GetAttribute (string elementId, string attribute)
 Gets an attribute of an element by ID string value = browser.MagicHelper.GetAttribute("element123", "value");.
void SetAttribute (string elementId, string attribute, string value)
 Sets an attribute of an element by ID browser.MagicHelper.SetAttribute("element123", "disabled", "true");.
void SetRange (string elementId, int rangeValue)
void SetValueFromElement (string srcSelector, string destElementId)
 Sets the value of a destination element from a source element, by CSS selector browser.MagicHelper.SetValueFromElement("#source", "#dest");.
void LeftClick (string elementId)
 Performs a left click on an element by ID browser.MagicHelper.LeftClick("element123");.
void LeftDoubleClick (string elementId)
 Performs a left double click on an element by ID browser.MagicHelper.LeftDoubleClick("element123");.
void MiddleClick (string elementId)
 Performs a left click on an element by ID browser.MagicHelper.LeftClick("element123");.
void RightClick (string elementId)
 Performs a right click on an element by ID browser.MagicHelper.RightClick("element123");.
void SelectClick (string elementId, dynamic indexOrValue)
bool IsVisibleInViewport (string elementId)
 Checks if an element is visible in viewport by ID bool visible = browser.MagicHelper.IsVisibleInViewport("element123");.
bool IsEndOfPage ()
 Checks if the page is at the end bool end = browser.MagicHelper.IsEndOfPage();.
void Hover (string elementId)
 Hovers over an element by ID browser.MagicHelper.Hover("element123");.
void DragAndDrop (string elementId, int deltaX, int deltaY, int offsetX=0, int offsetY=0)
 Drags an element by ID and drops it at an offset from its current position browser.MagicHelper.DragAndDrop("element123", 100, 50);.
int WindowInnerHeight ()
 Gets the window inner height int height = browser.MagicHelper.WindowInnerHeight();.
int WindowInnerWidth ()
 Gets the window inner width int width = browser.MagicHelper.WindowInnerWidth();.
int WindowOuterHeight ()
 Gets the window outer height int height = browser.MagicHelper.WindowOuterHeight();.
int WindowOuterWidth ()
 Gets the window outer width int width = browser.MagicHelper.WindowOuterWidth();.
string Fetch (string url, string method=null, string body=null, string contentType=null, string[] headers=null, bool asBytes=false)
 Issues an API request from inside the page, so it carries the session the browser has already earned: its cookies, TLS fingerprint, header order and any anti-bot clearance. A relative url resolves against wherever the browser currently is. string json = browser.MagicHelper.Fetch("/api/search?page=1");.
int WindowPageOffsetX ()
 Gets the window page offset X int offset = browser.MagicHelper.WindowPageOffsetX();.
int WindowPageOffsetY ()
 Gets the window page offset Y int offset = browser.MagicHelper.WindowPageOffsetY();.
bool ElementFromPoint (string elementId, int x, int y)
 Gets the bounding client rect of an element by ID string rect = browser.MagicHelper.GetBoundingClientRect("element123");.
bool TrustedLeftClick (int x, int y, int holdMs=0)
 Clicks a viewport point through the browser's own input pipeline, so the page reads the event as trusted. browser.MagicHelper.TrustedLeftClick(120, 340);.
bool TrustedMiddleClick (int x, int y, int holdMs=0)
 Middle clicks a viewport point through the browser's own input pipeline, so the page reads the event as trusted. browser.MagicHelper.TrustedMiddleClick(120, 340);.
Rectangle GetBoundingClientRect (string elementId)
void HideElement (string elementId)
 Hides an element by ID browser.MagicHelper.HideElement("element123");.
void InjectScript (string script)
 Registers a script to run on every new document load. Persists until ClearInjectedScripts is called. browser.MagicHelper.InjectScript("window.__hooked = true;");.
string ExecuteJavaScript (string script)
 Runs a script once, on the page that is open, and hands back what it returned. Where InjectScript registers a script against every document from now on, this one runs and is gone. Needs Allow user scripts turned on for the extension, the same as InjectScript does. string title = browser.MagicHelper.ExecuteJavaScript("document.title");.
string GetDocumentStamp ()
 The url and the document identity, as timeOrigin and url separated by a bar.
A dedicated endpoint rather than a script: ExecuteJavaScript runs through userScripts.execute, which requires the profile to allow user scripts. This endpoint has no such requirement. string stamp = browser.MagicHelper.GetDocumentStamp();.
string GetHydrationScripts ()
 The page title, the NEXT_DATA payload and any React Flight chunks, as json.
Read from the document rather than its serialized markup. Script content is character data, so the payloads arrive unescaped and no HTML parsing is involved. string json = browser.MagicHelper.GetHydrationScripts();.
void ClearInjectedScripts ()
 Removes all scripts previously registered via InjectScript. browser.MagicHelper.ClearInjectedScripts();.
bool IsClickAble (string elementId)
 Checks if an element is clickable by ID NOTE: when called from GPAL, we will always provide one element or selector that retrieves one element someone rolling their own and calling this endpoint outside gpal could result in multiple elements, so return the first result bool clickable = browser.MagicHelper.IsClickAble("element123");.
bool IsDisplayed (string elementId)
 Checks if an element is visible, can also just check element.Displayed NOTE: when called from GPAL, we will always provide one element or selector that retrieves one element someone rolling their own and calling this endpoint outside gpal could result in multiple elements, so return the first result bool displayed = browser.MagicHelper.IsDisplayed("element123");.
bool IsEnabled (string elementId)
 Checks if an element is enabled NOTE: when called from GPAL, we will always provide one element or selector that retrieves one element someone rolling their own and calling this endpoint outside gpal could result in multiple elements, so return the first result bool enabled = browser.MagicHelper.IsEnabled("element123");.
void ClearReferrer ()
 Clears the referrer header browser.MagicHelper.ClearReferrer();.
GPALElement Evaluate (string xpath)
 Evaluates an XPath expression to locate a single element string elementId = browser.MagicHelper.Evaluate("//div[@id='example']");.
List< GPALElement > EvaluateAll (string xpath)
 Evaluates an XPath expression to locate multiple elements string[] elementIds = browser.MagicHelper.EvaluateAll("//div");.
GPALElement EvaluatePersistent (string xpath)
 Evaluates an XPath expression to locate a single element string elementId = browser.MagicHelper.Evaluate("//div[@id='example']");.
List< GPALElement > EvaluateAllPersistent (string xpath)
 Evaluates an XPath expression to locate multiple elements string[] elementIds = browser.MagicHelper.EvaluateAll("//div");.
string GetUserAgent ()
 Gets the user agent string userAgent = browser.MagicHelper.GetUserAgent();.
string GetLanguages ()
 Gets the browser's preferred languages, most preferred first string languages = browser.MagicHelper.GetLanguages();.
void CaptureCalls (bool capture=true, string urlFragment=null, bool clear=false)
 Starts or stops recording what the page asks for. The extension watches with webRequest, so this records every request the browser makes rather than only the ones page script issued, and it keeps recording across navigations until it is stopped. browser.MagicHelper.CaptureCalls(true, "/api/search");.
string GetCapturedCalls ()
 Everything recorded so far, oldest first. string json = browser.MagicHelper.GetCapturedCalls();.
void FillInAppend (string elementId, string text)
 Append text to an element browser.MagicHelper.FillInAppend("input123", "Hello World");.
void FillInInsert (string elementId, string text)
 Inserts text to an element (prolly the same as append for the moment) browser.MagicHelper.FillInInsert("input123", "Hello World");.
void FillInOverwrite (string elementId, string text)
 Append text to an element browser.MagicHelper.FillInOverwrite("input123", "Hello World");.
void LeftClickAndDownload (string elementId, string filenameAndPath)
 Performs a left click and download on an element by ID browser.MagicHelper.LeftClickAndDownload("link123", filenameAndPath);.
void LeftClickAndUpload (string elementId, string filenameAndPath)
 Performs a left click and upload on an element by ID browser.MagicHelper.LeftClickAndUpload("link123", filename);.
void LeftClickAndUpload (string elementId, GPALFile filenamesAndPaths)
 Performs a left click and upload on an element by ID browser.MagicHelper.LeftClickAndUpload("link123", filename);.
GPALElement QuerySelector (string css)
 Queries a single element using a CSS selector string elementId = browser.MagicHelper.QuerySelector(".example");.
List< GPALElement > QuerySelectors (string css)
 Queries multiple elements using a CSS selector string[] elementIds = browser.MagicHelper.QuerySelectors(".example");.
GPALElement QueryPersistentSelector (string css)
 Queries a single element using a CSS selector string elementId = browser.MagicHelper.QuerySelector(".example");.
List< GPALElement > QueryPersistentSelectors (string css)
 Queries multiple elements using a CSS selector string[] elementIds = browser.MagicHelper.QuerySelectors(".example");.
void ScrollWindow (int hPixels, int vPixels)
 Scrolls the window by horizontal and vertical pixels browser.MagicHelper.ScrollWindow(100, 200);.
void SendKey (byte vkcode)
 Sends a single key browser.MagicHelper.SendKey("Enter");.
void SendString (string text, int delayMs=0)
 Sends a string of text browser.MagicHelper.SendString("Hello World");.
void SwitchToDefaultContent ()
 Switches to the default content browser.MagicHelper.SwitchToDefaultContent();.
void SwitchToShadowRoot (string elementId)
 Switches to a shadow root by element ID browser.MagicHelper.SwitchToShadowRoot("shadow123");.
WindowTuple OpenWindow (GPALUrl URL=null)
WindowTuple GoToWindow (dynamic urlOrId)
string CloseBrowser ()
 Closes every window the browser has, which is how an extension asks the browser hosting it to quit. browser.MagicHelper.CloseBrowser();.
WindowTuple CloseWindow (dynamic urlOrId)
WindowTuple GetCurrentWindow ()
string GetBrowserSettings ()
 Gets browser settings string settings = browser.MagicHelper.GetBrowserSettings();.
string GetGpalSettings ()
 Gets GPAL settings string settings = browser.MagicHelper.GetGpalSettings();.
string GetSettings ()
 Gets general settings string settings = browser.MagicHelper.GetSettings();.
string GetWorkflow ()
 Gets the workflow string workflow = browser.MagicHelper.GetWorkflow();.
Process LaunchBrowser (Browser browser, GPALUrl URL, List< string > additionalArguments=null)
bool TopBrowser (Process process)
 Brings the browser window to the top bool success = browser.MagicHelper.TopBrowser(process);.

Static Public Member Functions

static string GetRandomStarWarsQuery ()
 Use the Star Wars API to generate random search terms for our google cookies we will create.
static string GetFullUrl (string url, IBrowser browser, out bool areRobotsAllowed, bool noRobotsCheck=false)
static int CalculateHash (Dictionary< string, object > attributes)
 Calculates a consistent integer hash from a dictionary of attributes.
static string GetUserAgentString (BrowserType browserType)
 Get chrome or edge useragent string based upon what is installed on this system This looks up the versions in the registry to create the useragent string.
Static because it reads nothing but the registry and the GPALSettings templates, so it must not require a browser to exist. Reaching it through GPAL.MagicHelper did, since that is MagicHelpers[0].

Detailed Description

Definition at line 250 of file MagicHelper.cs.

Member Function Documentation

◆ Back()

void GenerallyPositive.Browser.MagicHelper.Back ( )

Navigates browser history back browser.MagicHelper.Back();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 304 of file MagicHelper.cs.

◆ CalculateHash()

int GenerallyPositive.Browser.MagicHelper.CalculateHash ( Dictionary< string, object > attributes)
static

Calculates a consistent integer hash from a dictionary of attributes.

Parameters
attributesA Dictionary<string, object> containing the attributes.
Returns
A 32-bit integer hash.

Definition at line 2777 of file MagicHelper.cs.

◆ CaptureCalls()

void GenerallyPositive.Browser.MagicHelper.CaptureCalls ( bool capture = true,
string urlFragment = null,
bool clear = false )

Starts or stops recording what the page asks for. The extension watches with webRequest, so this records every request the browser makes rather than only the ones page script issued, and it keeps recording across navigations until it is stopped. browser.MagicHelper.CaptureCalls(true, "/api/search");.

Parameters
captureTrue to record, false to stop
urlFragmentRecord only urls holding this, or null for everything
clearTrue to forget what was already recorded before starting

Definition at line 1518 of file MagicHelper.cs.

◆ CaptureVisibleTab()

string GenerallyPositive.Browser.MagicHelper.CaptureVisibleTab ( )

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 309 of file MagicHelper.cs.

◆ CheckNetworkIdle()

string GenerallyPositive.Browser.MagicHelper.CheckNetworkIdle ( int? maxConnections = null,
int? timeoutMs = null,
int? pruneMs = null )

Reports whether the network is idle.

Each parameter is optional and defaults to the browser setting: WithNetworkIdleMaxConnections, WithNetworkIdleTimeoutMs and WithNetworkIdlePruneMs. Called with no arguments it matches what GPAL checks after a navigation. bool idle = browser.MagicHelper.CheckNetworkIdle(5);.

Parameters
maxConnectionsConnections that still count as idle
timeoutMsHow long to wait for the network to settle
pruneMsHow long recorded traffic is kept before it is forgotten
Returns
Whether network is idle

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 325 of file MagicHelper.cs.

◆ ClearInjectedScripts()

void GenerallyPositive.Browser.MagicHelper.ClearInjectedScripts ( )

Removes all scripts previously registered via InjectScript. browser.MagicHelper.ClearInjectedScripts();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1396 of file MagicHelper.cs.

◆ ClearReferrer()

void GenerallyPositive.Browser.MagicHelper.ClearReferrer ( )

Clears the referrer header browser.MagicHelper.ClearReferrer();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1441 of file MagicHelper.cs.

◆ CloseBrowser()

string GenerallyPositive.Browser.MagicHelper.CloseBrowser ( )

Closes every window the browser has, which is how an extension asks the browser hosting it to quit. browser.MagicHelper.CloseBrowser();.

Returns
The acknowledgement, sent before the windows go because the last one ends the extension too

Definition at line 1728 of file MagicHelper.cs.

◆ CloseTab()

TabTuple GenerallyPositive.Browser.MagicHelper.CloseTab ( dynamic URLorTabId = null)

Closes a tab by URL or tab ID TabTuple closed = browser.MagicHelper.CloseTab("https://example.com");.

Parameters
URLorTabIdURL or tab ID to close
Returns
Closed tab details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 347 of file MagicHelper.cs.

◆ CloseWindow()

WindowTuple GenerallyPositive.Browser.MagicHelper.CloseWindow ( dynamic urlOrId)

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1733 of file MagicHelper.cs.

◆ DeleteStorage()

bool GenerallyPositive.Browser.MagicHelper.DeleteStorage ( WebsiteStorageType storageType,
bool deleteAcrossOrigins = false,
string domain = null,
string path = null,
string key = null,
string storeName = null )

Delete the type of storage type specified, if any parameter is missing, then that is a wildcard to delete all, from that domain and down or across domains if omitted.

Parameters
storageTypecookie, localStorage, sessopmStprage. indexedDb, cache
deleteAcrossOriginsOttoMagic only: true = delete across origins if no domain supplied
domainwebsite domain only
pathpath after the domain
keyobject to delete
storeNamethe storeName for indexedDb
Returns
true or false it worked

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 372 of file MagicHelper.cs.

◆ DragAndDrop()

void GenerallyPositive.Browser.MagicHelper.DragAndDrop ( string elementId,
int deltaX,
int deltaY,
int offsetX = 0,
int offsetY = 0 )

Drags an element by ID and drops it at an offset from its current position browser.MagicHelper.DragAndDrop("element123", 100, 50);.

Parameters
elementIdThe element ID
deltaXThe horizontal offset, in pixels, to drop the element
deltaYThe vertical offset, in pixels, to drop the element
offsetXHorizontal grab offset, in pixels, within the element to start the drag from
offsetYVertical grab offset, in pixels, within the element to start the drag from

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1162 of file MagicHelper.cs.

◆ ElementFromPoint()

bool GenerallyPositive.Browser.MagicHelper.ElementFromPoint ( string elementId,
int x,
int y )

Gets the bounding client rect of an element by ID string rect = browser.MagicHelper.GetBoundingClientRect("element123");.

Parameters
elementIdThe element ID
Returns
The bounding client rect

Whether a click at this viewport point would reach the element.

Parameters
elementIdThe element that should receive the click
xViewport x
yViewport y
Returns
True when the element, or something inside it, is what is at that point

Definition at line 1268 of file MagicHelper.cs.

◆ Evaluate()

GPALElement GenerallyPositive.Browser.MagicHelper.Evaluate ( string xpath)

Evaluates an XPath expression to locate a single element string elementId = browser.MagicHelper.Evaluate("//div[@id='example']");.

Parameters
xpathThe XPath expression
Returns
The element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1452 of file MagicHelper.cs.

◆ EvaluateAll()

List< GPALElement > GenerallyPositive.Browser.MagicHelper.EvaluateAll ( string xpath)

Evaluates an XPath expression to locate multiple elements string[] elementIds = browser.MagicHelper.EvaluateAll("//div");.

Parameters
xpathThe XPath expression
Returns
Array of element IDs

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1463 of file MagicHelper.cs.

◆ EvaluateAllPersistent()

List< GPALElement > GenerallyPositive.Browser.MagicHelper.EvaluateAllPersistent ( string xpath)

Evaluates an XPath expression to locate multiple elements string[] elementIds = browser.MagicHelper.EvaluateAll("//div");.

Parameters
xpathThe XPath expression
Returns
Array of element IDs

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1484 of file MagicHelper.cs.

◆ EvaluatePersistent()

GPALElement GenerallyPositive.Browser.MagicHelper.EvaluatePersistent ( string xpath)

Evaluates an XPath expression to locate a single element string elementId = browser.MagicHelper.Evaluate("//div[@id='example']");.

Parameters
xpathThe XPath expression
Returns
The element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1473 of file MagicHelper.cs.

◆ ExecuteJavaScript()

string GenerallyPositive.Browser.MagicHelper.ExecuteJavaScript ( string script)

Runs a script once, on the page that is open, and hands back what it returned. Where InjectScript registers a script against every document from now on, this one runs and is gone. Needs Allow user scripts turned on for the extension, the same as InjectScript does. string title = browser.MagicHelper.ExecuteJavaScript("document.title");.

Parameters
scriptThe JavaScript code to run
Returns
What the script returned, as json

Definition at line 1355 of file MagicHelper.cs.

◆ Fetch()

string GenerallyPositive.Browser.MagicHelper.Fetch ( string url,
string method = null,
string body = null,
string contentType = null,
string[] headers = null,
bool asBytes = false )

Issues an API request from inside the page, so it carries the session the browser has already earned: its cookies, TLS fingerprint, header order and any anti-bot clearance. A relative url resolves against wherever the browser currently is. string json = browser.MagicHelper.Fetch("/api/search?page=1");.

Parameters
urlUrl to request, relative or absolute
methodHTTP verb, GET when null
bodyRequest body, or null for none
contentTypeContent type of the body
headersExtra request headers, flattened to name, value, name, value
Returns
The response body, or null if the fetch could not be made

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1219 of file MagicHelper.cs.

◆ FillInAppend()

void GenerallyPositive.Browser.MagicHelper.FillInAppend ( string elementId,
string text )

Append text to an element browser.MagicHelper.FillInAppend("input123", "Hello World");.

Parameters
elementIdThe element ID
textThe text to input

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1544 of file MagicHelper.cs.

◆ FillInInsert()

void GenerallyPositive.Browser.MagicHelper.FillInInsert ( string elementId,
string text )

Inserts text to an element (prolly the same as append for the moment) browser.MagicHelper.FillInInsert("input123", "Hello World");.

Parameters
elementIdThe element ID
textThe text to input

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1555 of file MagicHelper.cs.

◆ FillInOverwrite()

void GenerallyPositive.Browser.MagicHelper.FillInOverwrite ( string elementId,
string text )

Append text to an element browser.MagicHelper.FillInOverwrite("input123", "Hello World");.

Parameters
elementIdThe element ID
textThe text to input

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1566 of file MagicHelper.cs.

◆ FireChangeEvent()

void GenerallyPositive.Browser.MagicHelper.FireChangeEvent ( string elementId)

Fires a change event on an element by ID browser.MagicHelper.FireChangeEvent("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 941 of file MagicHelper.cs.

◆ Focus()

void GenerallyPositive.Browser.MagicHelper.Focus ( string elementId)

Focuses an element by ID browser.MagicHelper.Focus("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 931 of file MagicHelper.cs.

◆ Forward()

void GenerallyPositive.Browser.MagicHelper.Forward ( )

Navigates browser history forward browser.MagicHelper.Forward();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 456 of file MagicHelper.cs.

◆ FullScreen()

void GenerallyPositive.Browser.MagicHelper.FullScreen ( )

Sets browser to full screen browser.MagicHelper.FullScreen();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 465 of file MagicHelper.cs.

◆ Get()

string GenerallyPositive.Browser.MagicHelper.Get ( GPALUrl URL)

Navigates to a URL string result = browser.MagicHelper.Get("https://example.com");.

Parameters
URLThe URL to navigate to
Returns
The navigation result

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 476 of file MagicHelper.cs.

◆ GetAttribute()

string GenerallyPositive.Browser.MagicHelper.GetAttribute ( string elementId,
string attribute )

Gets an attribute of an element by ID string value = browser.MagicHelper.GetAttribute("element123", "value");.

Parameters
elementIdThe element ID
attributeThe attribute name
Returns
The attribute value

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1039 of file MagicHelper.cs.

◆ GetBoundingClientRect()

Rectangle GenerallyPositive.Browser.MagicHelper.GetBoundingClientRect ( string elementId)

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1299 of file MagicHelper.cs.

◆ GetBrowserSettings()

string GenerallyPositive.Browser.MagicHelper.GetBrowserSettings ( )

Gets browser settings string settings = browser.MagicHelper.GetBrowserSettings();.

Returns
The browser settings as a string

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1752 of file MagicHelper.cs.

◆ GetCapturedCalls()

string GenerallyPositive.Browser.MagicHelper.GetCapturedCalls ( )

Everything recorded so far, oldest first. string json = browser.MagicHelper.GetCapturedCalls();.

Returns
The recorded calls as json, holding capturing, filter, dropped and calls

Definition at line 1533 of file MagicHelper.cs.

◆ GetContentAndCss()

string GenerallyPositive.Browser.MagicHelper.GetContentAndCss ( string elementId)

Gets content and CSS for a elementId string content = browser.MagicHelper.GetContentAndCss(elementId);.

Parameters
elementIdThe elementId
Returns
The content and CSS

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 497 of file MagicHelper.cs.

◆ GetCssAttributes()

Dictionary< string, object > GenerallyPositive.Browser.MagicHelper.GetCssAttributes ( string elementId)

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 509 of file MagicHelper.cs.

◆ GetCurrentUrl()

string GenerallyPositive.Browser.MagicHelper.GetCurrentUrl ( )

Gets the current URL string url = browser.MagicHelper.GetCurrentUrl();.

Returns
The current URL

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 527 of file MagicHelper.cs.

◆ GetCurrentWindow()

WindowTuple GenerallyPositive.Browser.MagicHelper.GetCurrentWindow ( )

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1741 of file MagicHelper.cs.

◆ GetDocumentStamp()

string GenerallyPositive.Browser.MagicHelper.GetDocumentStamp ( )

The url and the document identity, as timeOrigin and url separated by a bar.
A dedicated endpoint rather than a script: ExecuteJavaScript runs through userScripts.execute, which requires the profile to allow user scripts. This endpoint has no such requirement. string stamp = browser.MagicHelper.GetDocumentStamp();.

Returns
timeOrigin and url separated by a bar, or null when the page could not answer

Definition at line 1367 of file MagicHelper.cs.

◆ GetDomAttributes()

Dictionary< string, object > GenerallyPositive.Browser.MagicHelper.GetDomAttributes ( string elementId)

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 513 of file MagicHelper.cs.

◆ GetDomProperties()

Dictionary< string, object > GenerallyPositive.Browser.MagicHelper.GetDomProperties ( string elementId)

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 517 of file MagicHelper.cs.

◆ GetElementAttributeHash()

string GenerallyPositive.Browser.MagicHelper.GetElementAttributeHash ( string elementId)

Gets the attribute hash of an element string hash = browser.MagicHelper.GetElementAttributeHash();.

Returns
The attribute hash

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 997 of file MagicHelper.cs.

◆ GetFullUrl()

string GenerallyPositive.Browser.MagicHelper.GetFullUrl ( string url,
IBrowser browser,
out bool areRobotsAllowed,
bool noRobotsCheck = false )
static

Definition at line 2735 of file MagicHelper.cs.

◆ GetGpalSettings()

string GenerallyPositive.Browser.MagicHelper.GetGpalSettings ( )

Gets GPAL settings string settings = browser.MagicHelper.GetGpalSettings();.

Returns
The GPAL settings as a string

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1762 of file MagicHelper.cs.

◆ GetHydrationScripts()

string GenerallyPositive.Browser.MagicHelper.GetHydrationScripts ( )

The page title, the NEXT_DATA payload and any React Flight chunks, as json.
Read from the document rather than its serialized markup. Script content is character data, so the payloads arrive unescaped and no HTML parsing is involved. string json = browser.MagicHelper.GetHydrationScripts();.

Returns
Json holding title, nextData and flightChunks, or null when the page could not answer

Definition at line 1387 of file MagicHelper.cs.

◆ GetLanguages()

string GenerallyPositive.Browser.MagicHelper.GetLanguages ( )

Gets the browser's preferred languages, most preferred first string languages = browser.MagicHelper.GetLanguages();.

Returns
The languages, comma separated

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1504 of file MagicHelper.cs.

◆ GetOptions()

List< GPALElement > GenerallyPositive.Browser.MagicHelper.GetOptions ( string elementId)

Get select menu option items.

Parameters
elementId
Returns

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1007 of file MagicHelper.cs.

◆ GetPageSource()

string GenerallyPositive.Browser.MagicHelper.GetPageSource ( )

Get the html source of the current page.

Returns

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1017 of file MagicHelper.cs.

◆ GetParentNode()

GPALElement GenerallyPositive.Browser.MagicHelper.GetParentNode ( string elementId)

Gets the parent node of an element by ID string parent = browser.MagicHelper.GetParentNode("element123");.

Parameters
elementIdThe element ID
Returns
The parent node

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1027 of file MagicHelper.cs.

◆ GetRandomStarWarsQuery()

string GenerallyPositive.Browser.MagicHelper.GetRandomStarWarsQuery ( )
static

Use the Star Wars API to generate random search terms for our google cookies we will create.

Returns

Definition at line 2665 of file MagicHelper.cs.

◆ GetReadyStatus()

string GenerallyPositive.Browser.MagicHelper.GetReadyStatus ( )

Gets the ready status NOTE: if no page is loaded, this will return null cause there is no content script. so it's "complete". string status = browser.MagicHelper.GetReadyStatus();.

Returns
The ready status

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 538 of file MagicHelper.cs.

◆ GetSettings()

string GenerallyPositive.Browser.MagicHelper.GetSettings ( )

Gets general settings string settings = browser.MagicHelper.GetSettings();.

Returns
The general settings as a string

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1772 of file MagicHelper.cs.

◆ GetShadowRoot()

GPALElement GenerallyPositive.Browser.MagicHelper.GetShadowRoot ( string elementId)

Gets the shadow root for an elementId GPALElement root = browser.MagicHelper.GetShadowRoot(elementId);.

Parameters
elementIdThe elementId
Returns
The shadow root element

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 589 of file MagicHelper.cs.

◆ GetStorage()

string GenerallyPositive.Browser.MagicHelper.GetStorage ( WebsiteStorageType storageType,
string domain = null,
string path = null,
string key = null,
string storeName = null )

Get the type of storage type specified, if any parameter is missing, then that is a wildcard to get all, from that domain and down or across domains if omitted.

Parameters
storageTypecookie, localStorage, sessopmStprage. indexedDb, cache
domainwebsite domain only
pathpath after the domain
keyobject to delete
Returns
List<StorageAction>

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 406 of file MagicHelper.cs.

◆ GetUserAgent()

string GenerallyPositive.Browser.MagicHelper.GetUserAgent ( )

Gets the user agent string userAgent = browser.MagicHelper.GetUserAgent();.

Returns
The user agent string

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1494 of file MagicHelper.cs.

◆ GetUserAgentString()

string GenerallyPositive.Browser.MagicHelper.GetUserAgentString ( BrowserType browserType)
static

Get chrome or edge useragent string based upon what is installed on this system This looks up the versions in the registry to create the useragent string.
Static because it reads nothing but the registry and the GPALSettings templates, so it must not require a browser to exist. Reaching it through GPAL.MagicHelper did, since that is MagicHelpers[0].

Parameters
browserType
Returns

Definition at line 2807 of file MagicHelper.cs.

◆ GetWindowRectangle()

Rectangle GenerallyPositive.Browser.MagicHelper.GetWindowRectangle ( )

Returns the browser window inner/outer height/widge { y: window.innerHeight, x: window.width, height: window.outerHeight, width: window.outerWidth }.

Returns

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 950 of file MagicHelper.cs.

◆ GetWorkflow()

string GenerallyPositive.Browser.MagicHelper.GetWorkflow ( )

Gets the workflow string workflow = browser.MagicHelper.GetWorkflow();.

Returns
The workflow as a string

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1782 of file MagicHelper.cs.

◆ GoTo()

TabTuple GenerallyPositive.Browser.MagicHelper.GoTo ( GPALUrl URL)

Navigates to a URL TabTuple tab = browser.MagicHelper.Goto("https://example.com");.

Parameters
URLThe URL to navigate to
Returns
The tab details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 600 of file MagicHelper.cs.

◆ GotoTab()

TabTuple GenerallyPositive.Browser.MagicHelper.GotoTab ( dynamic URLorTabId)

Navigates to a tab by URL or tab ID TabTuple tab = browser.MagicHelper.GotoTab("https://example.com");.

Parameters
URLorTabIdURL or tab ID to navigate to
Returns
The tab details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 624 of file MagicHelper.cs.

◆ GoToWindow()

WindowTuple GenerallyPositive.Browser.MagicHelper.GoToWindow ( dynamic urlOrId)

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1716 of file MagicHelper.cs.

◆ HideElement()

void GenerallyPositive.Browser.MagicHelper.HideElement ( string elementId)

Hides an element by ID browser.MagicHelper.HideElement("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1326 of file MagicHelper.cs.

◆ Hover()

void GenerallyPositive.Browser.MagicHelper.Hover ( string elementId)

Hovers over an element by ID browser.MagicHelper.Hover("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1148 of file MagicHelper.cs.

◆ InFrame()

void GenerallyPositive.Browser.MagicHelper.InFrame ( string elementId)

Switches context to iframe browser.MagicHelper.InFrame();NOTE: InFrame and InElement are identical in implementation.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 660 of file MagicHelper.cs.

◆ InjectScript()

void GenerallyPositive.Browser.MagicHelper.InjectScript ( string script)

Registers a script to run on every new document load. Persists until ClearInjectedScripts is called. browser.MagicHelper.InjectScript("window.__hooked = true;");.

Parameters
scriptThe JavaScript code to inject

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1336 of file MagicHelper.cs.

◆ IsClickAble()

bool GenerallyPositive.Browser.MagicHelper.IsClickAble ( string elementId)

Checks if an element is clickable by ID NOTE: when called from GPAL, we will always provide one element or selector that retrieves one element someone rolling their own and calling this endpoint outside gpal could result in multiple elements, so return the first result bool clickable = browser.MagicHelper.IsClickAble("element123");.

Parameters
elementIdThe element ID
Returns
Whether the element is clickable

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1409 of file MagicHelper.cs.

◆ IsDisplayed()

bool GenerallyPositive.Browser.MagicHelper.IsDisplayed ( string elementId)

Checks if an element is visible, can also just check element.Displayed NOTE: when called from GPAL, we will always provide one element or selector that retrieves one element someone rolling their own and calling this endpoint outside gpal could result in multiple elements, so return the first result bool displayed = browser.MagicHelper.IsDisplayed("element123");.

Parameters
elementIdThe element ID
Returns
Whether the element is clickable

Definition at line 1421 of file MagicHelper.cs.

◆ IsEnabled()

bool GenerallyPositive.Browser.MagicHelper.IsEnabled ( string elementId)

Checks if an element is enabled NOTE: when called from GPAL, we will always provide one element or selector that retrieves one element someone rolling their own and calling this endpoint outside gpal could result in multiple elements, so return the first result bool enabled = browser.MagicHelper.IsEnabled("element123");.

Parameters
elementIdThe element ID
Returns
Whether the element is clickable

Definition at line 1433 of file MagicHelper.cs.

◆ IsEndOfPage()

bool GenerallyPositive.Browser.MagicHelper.IsEndOfPage ( )

Checks if the page is at the end bool end = browser.MagicHelper.IsEndOfPage();.

Returns
Whether the page is at the end

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1138 of file MagicHelper.cs.

◆ IsVisibleInViewport()

bool GenerallyPositive.Browser.MagicHelper.IsVisibleInViewport ( string elementId)

Checks if an element is visible in viewport by ID bool visible = browser.MagicHelper.IsVisibleInViewport("element123");.

Parameters
elementIdThe element ID
Returns
Whether the element is visible

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1128 of file MagicHelper.cs.

◆ LaunchBrowser()

Process GenerallyPositive.Browser.MagicHelper.LaunchBrowser ( Browser browser,
GPALUrl URL,
List< string > additionalArguments = null )

Definition at line 1864 of file MagicHelper.cs.

◆ LeftClick()

void GenerallyPositive.Browser.MagicHelper.LeftClick ( string elementId)

Performs a left click on an element by ID browser.MagicHelper.LeftClick("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1077 of file MagicHelper.cs.

◆ LeftClickAndDownload()

void GenerallyPositive.Browser.MagicHelper.LeftClickAndDownload ( string elementId,
string filenameAndPath )

Performs a left click and download on an element by ID browser.MagicHelper.LeftClickAndDownload("link123", filenameAndPath);.

Parameters
elementIdThe element ID
filenameAndPathWhere the file the click downloads is to be saved; the extension is given its filename, see WithDownloadFile

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1577 of file MagicHelper.cs.

◆ LeftClickAndUpload() [1/2]

void GenerallyPositive.Browser.MagicHelper.LeftClickAndUpload ( string elementId,
GPALFile filenamesAndPaths )

Performs a left click and upload on an element by ID browser.MagicHelper.LeftClickAndUpload("link123", filename);.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1597 of file MagicHelper.cs.

◆ LeftClickAndUpload() [2/2]

void GenerallyPositive.Browser.MagicHelper.LeftClickAndUpload ( string elementId,
string filenameAndPath )

Performs a left click and upload on an element by ID browser.MagicHelper.LeftClickAndUpload("link123", filename);.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1587 of file MagicHelper.cs.

◆ LeftDoubleClick()

void GenerallyPositive.Browser.MagicHelper.LeftDoubleClick ( string elementId)

Performs a left double click on an element by ID browser.MagicHelper.LeftDoubleClick("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1088 of file MagicHelper.cs.

◆ Maximize()

void GenerallyPositive.Browser.MagicHelper.Maximize ( )

Maximizes the browser window browser.MagicHelper.Maximize();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 678 of file MagicHelper.cs.

◆ MiddleClick()

void GenerallyPositive.Browser.MagicHelper.MiddleClick ( string elementId)

Performs a left click on an element by ID browser.MagicHelper.LeftClick("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1098 of file MagicHelper.cs.

◆ Minimize()

void GenerallyPositive.Browser.MagicHelper.Minimize ( )

Minimizes the browser window browser.MagicHelper.Minimize();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 669 of file MagicHelper.cs.

◆ MoveTo()

void GenerallyPositive.Browser.MagicHelper.MoveTo ( string elementId)

Scrolls an element into view by ID browser.MagicHelper.ScrollIntoView("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 688 of file MagicHelper.cs.

◆ NewTab()

TabTuple GenerallyPositive.Browser.MagicHelper.NewTab ( GPALUrl URL = null)

Opens a new tab with optional URL TabTuple tab = browser.MagicHelper.NewTab("https://example.com");.

Parameters
URLThe URL to open
Returns
The tab details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 709 of file MagicHelper.cs.

◆ NextTab()

TabTuple GenerallyPositive.Browser.MagicHelper.NextTab ( )

Switches to the next tab TabTuple tab = browser.MagicHelper.NextTab();.

Returns
The tab details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 727 of file MagicHelper.cs.

◆ NextWindow()

WindowTuple GenerallyPositive.Browser.MagicHelper.NextWindow ( )

Switches to the next window WindowTuple window = browser.MagicHelper.NextWindow();.

Returns
The window details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 748 of file MagicHelper.cs.

◆ Normal()

void GenerallyPositive.Browser.MagicHelper.Normal ( )

Restores the browser window to normal browser.MagicHelper.Normal();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 698 of file MagicHelper.cs.

◆ OpenWindow()

WindowTuple GenerallyPositive.Browser.MagicHelper.OpenWindow ( GPALUrl URL = null)

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1703 of file MagicHelper.cs.

◆ OverrideReferrer()

void GenerallyPositive.Browser.MagicHelper.OverrideReferrer ( string referrer)

Overrides the referrer URL browser.MagicHelper.OverrideReferrer("https://google.com");.

Parameters
referrerThe referrer URL

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 758 of file MagicHelper.cs.

◆ PageDown()

void GenerallyPositive.Browser.MagicHelper.PageDown ( )

Scrolls the page down browser.MagicHelper.PageDown();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 777 of file MagicHelper.cs.

◆ PageEnd()

void GenerallyPositive.Browser.MagicHelper.PageEnd ( )

Scrolls to the page end browser.MagicHelper.PageEnd();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 786 of file MagicHelper.cs.

◆ PageTop()

void GenerallyPositive.Browser.MagicHelper.PageTop ( )

Scrolls to the page top browser.MagicHelper.PageTop();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 795 of file MagicHelper.cs.

◆ PageUp()

void GenerallyPositive.Browser.MagicHelper.PageUp ( )

Scrolls the page up browser.MagicHelper.PageUp();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 804 of file MagicHelper.cs.

◆ PressModifierKey()

void GenerallyPositive.Browser.MagicHelper.PressModifierKey ( ModifierKeys modifierKeys)

Press the specified modifier keys.

Parameters
modifierKeys

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 812 of file MagicHelper.cs.

◆ PreviousTab()

TabTuple GenerallyPositive.Browser.MagicHelper.PreviousTab ( )

Switches to the previous tab TabTuple tab = browser.MagicHelper.PreviousTab();.

Returns
The tab details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 821 of file MagicHelper.cs.

◆ PreviousWindow()

WindowTuple GenerallyPositive.Browser.MagicHelper.PreviousWindow ( )

Switches to the previous window WindowTuple window = browser.MagicHelper.PreviousWindow();.

Returns
The window details

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 832 of file MagicHelper.cs.

◆ QueryPersistentSelector()

GPALElement GenerallyPositive.Browser.MagicHelper.QueryPersistentSelector ( string css)

Queries a single element using a CSS selector string elementId = browser.MagicHelper.QuerySelector(".example");.

Parameters
cssThe CSS selector
Returns
The element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1632 of file MagicHelper.cs.

◆ QueryPersistentSelectors()

List< GPALElement > GenerallyPositive.Browser.MagicHelper.QueryPersistentSelectors ( string css)

Queries multiple elements using a CSS selector string[] elementIds = browser.MagicHelper.QuerySelectors(".example");.

Parameters
cssThe CSS selector
Returns
Array of element IDs

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1645 of file MagicHelper.cs.

◆ QuerySelector()

GPALElement GenerallyPositive.Browser.MagicHelper.QuerySelector ( string css)

Queries a single element using a CSS selector string elementId = browser.MagicHelper.QuerySelector(".example");.

Parameters
cssThe CSS selector
Returns
The element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1609 of file MagicHelper.cs.

◆ QuerySelectors()

List< GPALElement > GenerallyPositive.Browser.MagicHelper.QuerySelectors ( string css)

Queries multiple elements using a CSS selector string[] elementIds = browser.MagicHelper.QuerySelectors(".example");.

Parameters
cssThe CSS selector
Returns
Array of element IDs

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1621 of file MagicHelper.cs.

◆ Refresh()

void GenerallyPositive.Browser.MagicHelper.Refresh ( )

Refreshes the current page browser.MagicHelper.Refresh();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 840 of file MagicHelper.cs.

◆ ReleaseModifierKey()

void GenerallyPositive.Browser.MagicHelper.ReleaseModifierKey ( ModifierKeys modifierKeys)

Press the specified modifier keys.

Parameters
modifierKeys

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 849 of file MagicHelper.cs.

◆ Restore()

void GenerallyPositive.Browser.MagicHelper.Restore ( )

Restores the browser window browser.MagicHelper.Restore();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 858 of file MagicHelper.cs.

◆ RightClick()

void GenerallyPositive.Browser.MagicHelper.RightClick ( string elementId)

Performs a right click on an element by ID browser.MagicHelper.RightClick("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1109 of file MagicHelper.cs.

◆ ScrollElement()

void GenerallyPositive.Browser.MagicHelper.ScrollElement ( string elementId,
int hPixels,
int vPixels )

Scrolls an element by horizontal and vertical pixels browser.MagicHelper.ScrollElement(100, 200);.

Parameters
hPixelsThe horizontal pixels
vPixelsThe vertical pixels

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 987 of file MagicHelper.cs.

◆ ScrollIntoView()

void GenerallyPositive.Browser.MagicHelper.ScrollIntoView ( string elementId)

Scrolls an element into view by ID browser.MagicHelper.ScrollIntoView("element123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 976 of file MagicHelper.cs.

◆ ScrollWindow()

void GenerallyPositive.Browser.MagicHelper.ScrollWindow ( int hPixels,
int vPixels )

Scrolls the window by horizontal and vertical pixels browser.MagicHelper.ScrollWindow(100, 200);.

Parameters
hPixelsThe horizontal pixels
vPixelsThe vertical pixels

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1655 of file MagicHelper.cs.

◆ ScrollWindowHorizontal()

void GenerallyPositive.Browser.MagicHelper.ScrollWindowHorizontal ( int pixels)

Scrolls the window horizontally by pixels browser.MagicHelper.ScrollWindowByHorizontal(100);.

Parameters
pixelsThe horizontal pixels

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 868 of file MagicHelper.cs.

◆ ScrollWindowVertical()

void GenerallyPositive.Browser.MagicHelper.ScrollWindowVertical ( int pixels)

Scrolls the window vertically by pixels browser.MagicHelper.ScrollWindowByVertical(100);.

Parameters
pixelsThe vertical pixels

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 878 of file MagicHelper.cs.

◆ SelectClick()

void GenerallyPositive.Browser.MagicHelper.SelectClick ( string elementId,
dynamic indexOrValue )

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1114 of file MagicHelper.cs.

◆ SendKey()

void GenerallyPositive.Browser.MagicHelper.SendKey ( byte vkcode)

Sends a single key browser.MagicHelper.SendKey("Enter");.

Parameters
keyThe key to send

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1666 of file MagicHelper.cs.

◆ SendString()

void GenerallyPositive.Browser.MagicHelper.SendString ( string text,
int delayMs = 0 )

Sends a string of text browser.MagicHelper.SendString("Hello World");.

Parameters
textThe text to send
delayMsInter-character pacing delay in milliseconds, forwarded to OttoMagic as "typingDelay". 0 sends the whole string atomically.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1677 of file MagicHelper.cs.

◆ SetAttribute()

void GenerallyPositive.Browser.MagicHelper.SetAttribute ( string elementId,
string attribute,
string value )

Sets an attribute of an element by ID browser.MagicHelper.SetAttribute("element123", "disabled", "true");.

Parameters
elementIdThe element ID
attributeThe attribute name
valueThe attribute value

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1051 of file MagicHelper.cs.

◆ SetGoogleReferrer()

void GenerallyPositive.Browser.MagicHelper.SetGoogleReferrer ( )

Overrides referrer stealthily browser.MagicHelper.SetGoogleReferrer();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 887 of file MagicHelper.cs.

◆ SetRange()

void GenerallyPositive.Browser.MagicHelper.SetRange ( string elementId,
int rangeValue )

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1056 of file MagicHelper.cs.

◆ SetStorage()

bool GenerallyPositive.Browser.MagicHelper.SetStorage ( WebsiteStorageType storageType,
string data,
string domain = null,
string path = null,
string key = null,
string storeName = null )

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 427 of file MagicHelper.cs.

◆ SetUserAgent()

void GenerallyPositive.Browser.MagicHelper.SetUserAgent ( string userAgent)

Overrides the browser's user agent string browser.MagicHelper.SetUserAgent("Mozilla/5.0 ...");.

Parameters
userAgentThe user agent string to use

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 768 of file MagicHelper.cs.

◆ SetValueFromElement()

void GenerallyPositive.Browser.MagicHelper.SetValueFromElement ( string srcSelector,
string destElementId )

Sets the value of a destination element from a source element, by CSS selector browser.MagicHelper.SetValueFromElement("#source", "#dest");.

Parameters
srcSelectorCSS selector identifying the source element to read the value from
destElementIdCSS selector identifying the destination element whose value is set

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1067 of file MagicHelper.cs.

◆ SwitchToDefaultContent()

void GenerallyPositive.Browser.MagicHelper.SwitchToDefaultContent ( )

Switches to the default content browser.MagicHelper.SwitchToDefaultContent();.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1687 of file MagicHelper.cs.

◆ SwitchToElement()

void GenerallyPositive.Browser.MagicHelper.SwitchToElement ( string elementId)

Switches context to an element browser.MagicHelper.InElement();NOTE: InFrame and InElement are identical in implementation.

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 650 of file MagicHelper.cs.

◆ SwitchToShadowRoot()

void GenerallyPositive.Browser.MagicHelper.SwitchToShadowRoot ( string elementId)

Switches to a shadow root by element ID browser.MagicHelper.SwitchToShadowRoot("shadow123");.

Parameters
elementIdThe element ID

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1697 of file MagicHelper.cs.

◆ TabCount()

int GenerallyPositive.Browser.MagicHelper.TabCount ( )

How many tabs the browser actually has open, which is not the same as how many GPAL opened. A tab can close itself, which is what a browser does with a tab whose first navigation turns into a download. int tabs = browser.MagicHelper.TabCount();.

Returns
The number of tabs open, or zero when the extension could not say

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 738 of file MagicHelper.cs.

◆ TopBrowser()

bool GenerallyPositive.Browser.MagicHelper.TopBrowser ( Process process)

Brings the browser window to the top bool success = browser.MagicHelper.TopBrowser(process);.

Parameters
processThe browser process
Returns
Whether the operation succeeded

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 2659 of file MagicHelper.cs.

◆ TrustedLeftClick()

bool GenerallyPositive.Browser.MagicHelper.TrustedLeftClick ( int x,
int y,
int holdMs = 0 )

Clicks a viewport point through the browser's own input pipeline, so the page reads the event as trusted. browser.MagicHelper.TrustedLeftClick(120, 340);.

Parameters
xViewport x to click
yViewport y to click
holdMsMilliseconds to hold the button down, 0 for an ordinary click
Returns
True when the click was made, false where the browser has no debugger to attach

Definition at line 1281 of file MagicHelper.cs.

◆ TrustedMiddleClick()

bool GenerallyPositive.Browser.MagicHelper.TrustedMiddleClick ( int x,
int y,
int holdMs = 0 )

Middle clicks a viewport point through the browser's own input pipeline, so the page reads the event as trusted. browser.MagicHelper.TrustedMiddleClick(120, 340);.

Parameters
xViewport x to click
yViewport y to click
holdMsMilliseconds to hold the button down, 0 for an ordinary click
Returns
True when the click was made, false where the browser has no debugger to attach

Definition at line 1294 of file MagicHelper.cs.

◆ WindowInnerHeight()

int GenerallyPositive.Browser.MagicHelper.WindowInnerHeight ( )

Gets the window inner height int height = browser.MagicHelper.WindowInnerHeight();.

Returns
The inner height

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1172 of file MagicHelper.cs.

◆ WindowInnerWidth()

int GenerallyPositive.Browser.MagicHelper.WindowInnerWidth ( )

Gets the window inner width int width = browser.MagicHelper.WindowInnerWidth();.

Returns
The inner width

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1182 of file MagicHelper.cs.

◆ WindowOuterHeight()

int GenerallyPositive.Browser.MagicHelper.WindowOuterHeight ( )

Gets the window outer height int height = browser.MagicHelper.WindowOuterHeight();.

Returns
The outer height

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1192 of file MagicHelper.cs.

◆ WindowOuterWidth()

int GenerallyPositive.Browser.MagicHelper.WindowOuterWidth ( )

Gets the window outer width int width = browser.MagicHelper.WindowOuterWidth();.

Returns
The outer width

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1202 of file MagicHelper.cs.

◆ WindowPageOffsetX()

int GenerallyPositive.Browser.MagicHelper.WindowPageOffsetX ( )

Gets the window page offset X int offset = browser.MagicHelper.WindowPageOffsetX();.

Returns
The page offset X

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1240 of file MagicHelper.cs.

◆ WindowPageOffsetY()

int GenerallyPositive.Browser.MagicHelper.WindowPageOffsetY ( )

Gets the window page offset Y int offset = browser.MagicHelper.WindowPageOffsetY();.

Returns
The page offset Y

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 1250 of file MagicHelper.cs.

◆ WindowScreenLeft()

int GenerallyPositive.Browser.MagicHelper.WindowScreenLeft ( )

Gets the window screen left position int left = browser.MagicHelper.WindowScreenLeft();.

Returns
The screen left position

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 911 of file MagicHelper.cs.

◆ WindowScreenTop()

int GenerallyPositive.Browser.MagicHelper.WindowScreenTop ( )

Gets the window screen top position int top = browser.MagicHelper.WindowScreenTop();.

Returns
The screen top position

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 921 of file MagicHelper.cs.

◆ WithDownloadFile()

void GenerallyPositive.Browser.MagicHelper.WithDownloadFile ( string downloadPath)

Names the file the next download should land under.
Only the leaf name is sent. The extension names a download through onDeterminingFilename, which takes a name relative to the browser's own download directory and rejects an absolute path outright, so the directory half of downloadPath would silently cost us the name as well. The file arrives in the browser's download directory and the download watcher moves it where it was asked to go. browser.MagicHelper.WithDownloadFile("c:\sdi\sample.pdf"); // the extension is sent sample.pdf.

Parameters
downloadPathWhere the file is to end up; the extension is given its filename

Implements GenerallyPositive.Browser.IMagicHelper.

Definition at line 901 of file MagicHelper.cs.


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