GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
Interfaces.cs
1// =============================================================================
2// GPAL - Generally Positive Automation Library
3// Copyright © 2026 Software Decisions, Inc. All rights reserved.
4//
5// This file is part of GPAL.
6// Licensed under the Business Source License 1.1
7//
8// Primary development, architecture, and vision by Michael B. Vederman,
9// CEO of Software Decisions, Inc., Texas.
10//
11// Internal development maintained privately.
12// Public releases appear on GitHub: https://github.com/SoftwareDecisionsInc/GPAL.
13//
14// See LICENSE for full terms, including Additional Use Grant.
15// =============================================================================
16
17using DocumentFormat.OpenXml.Drawing;
19using OpenQA.Selenium;
20using System;
21using System.Collections.Generic;
22using System.Diagnostics;
23using System.Drawing;
24using System.Linq;
25using System.Text;
26using System.Threading.Tasks;
28using static GenerallyPositive.Enums;
29using static GenerallyPositive.GPAL;
30
32/*
33var browser =
34 GPAL.Browser
35 // optional from here
36 .GlobalWaitOnDocumentReady(bool) // true - turn ON waiting for document.ready before returning from verb
37 .WithBrowser(BrowserType enum) // default chrome
38 .WithLoadImages(bool) // default false
39 .WithScrollIntoView(bool) // default false - follow each scraped element on screen
40 .WithOpenPDFExternally(bool) // default true
41 .WithDownloadFileTypes(string) // csv - defaults?
42 .WithOpenFileTypes(string) // csv - defaults?
43 // optional to here
44 .GoTo(URL)
45
46 // test document.ready()
47 // do we ever deal with before/after/during events
48 // on With, create Selector container for this UOW which ends in an action
49 .WithSelector(searchSelector)
50 .FillInFrom(string) /// WithHardware implies moving the mouse and clicks and enter text via keyboard emulation
51
52 // test document.ready()
53 // on With, create Selector container for this UOW which ends in an action
54 .GlobalWaitOnDocumentReady(bool) // false - turn OFF waiting for document.ready before returning from verb
55 .WithSelector(searchButtonSelector)
56 .LeftClick() /// WithHardware implies moving the mouse and clicks
57
58 // test document.ready()
59 // on using, create Selector container for this UOW which ends in an action
60 // TODO: how to say do not return sparesely populated arrays
61 .WithSelector(colum1DataSelector) // link .All at selector level
62 .WithSelector(colum2DataSelector) // description .All at selector level
63 .WithSelector(colum3DataSelector) // price .All at selector level
64 .WithSelector(colum4DataSelector) // image link .All at selector level
65 .WithSelector(colum5DataSelector) // repeat this one value in this column for all rows .Repeat at selector level
66 // indicates above selectors are repeated and get all on the current page matching pattern
67 .WithAll
68 .WithNextPageButton(nextPageSelector) // if not defined, only gets current page
69 .WithPages(10) // default is one page, but should be used in conjunction with above
70 .GetGrid() // change the return type to Tokens for manipulation/validation/saving
71
72 // test document.ready()
73 // tied to GPALGrid object
74 .WithHeader(columnAString)
75 .WithHeader(columnBString)
76 .WithHeader(columnCString)
77 .WithHeader(columnDString)
78 .WithHeader(columnEString)
79 .SaveToExcel(fileName) // return type is GPAL.browser
80
81 // the formal end of everything
82 .Close() // implies dispose, implement IDisposable on Browser
83
84 // end of iterations
85*/
88{
89 #region <BrowserInterfaces>
90 public interface IBrowser :
109 IAllowRun,
112 // IAllowOCRSettingsOrExecute,
117 IAllowToGPALObject<IBrowser>
118 {
119 // Public properties
120 bool? FileDownloaded { get; set; }
121 BrowserType BrowserType { get; }
122 IWebDriver BrowserDriver { get; }
127 string RestApiBaseUrl { get; }
128 int CurrentTabIdx { get; }
129 string CurrentUrl { get; }
130 string BrowserVersion { get; }
131 object JavaScriptResultObj { get; }
132 string JavaScriptResultStr { get; }
133 PuppeteerCommunicator PuppeteerCommunicator { get; }
134 IPuppeteerClient PuppeteerClient { get; }
135 int ServerResponseCode { get; set; } // CAVEAT: public set: unsure why visual studio will not let me use internal set in Broser without set here, like everywhere else
136 bool UseOttoMagic { get; }
137 bool UsePuppeteer { get; }
138 bool UseSelenium { get; }
139 AutomationEngine AutomationEngine { get; }
140 IRESTClient OttoMagicClient { get; }
141 [Settings(Description = "The hidden desktop this browser is running on, or null when it is on the visible one.")]
142 IHiddenDesktop HiddenDesktop { get; }
143 bool IsEndOfPage();
144 bool IsAlive { get; }
145 // Public methods not covered by existing interfaces
146 [Action(Description = "Remove the CallIf handler everywhere it has been set. Use this once you are done using the handler.")]
147 void RemoveCallIfHandlerEverywhere(CallIfDelegate func);
148 MagicHelper MagicHelper { get; }
149 }
150
154 public interface IHiddenDesktop
155 {
156 [Settings(Description = "What this desktop is called. Browsers naming the same one share it.")]
157 string Name { get; }
158 [Settings(Description = "How many visible top level windows are on it right now.")]
159 int WindowCount { get; }
160 [Browser(Description = "Put this desktop on the screen for the default time, then put yours back.")]
161 string Peek();
162 [Browser(Description = "Put this desktop on the screen for this many milliseconds, then put yours back.")]
163 string Peek(int forMs);
164 [Browser(Description = "Give up GPAL's handle on this desktop. Closes nothing running there.")]
165 void Close();
166 }
167
172 public interface IHiddenDesktops
173 {
174 [Settings(Description = "Every desktop made so far, in the order they were made.")]
175 IReadOnlyList<string> Names { get; }
176 [Settings(Description = "One desktop by name, so a workflow that did not keep the browser can still reach it.")]
177 IHiddenDesktop this[string desktopName] { get; }
178 [Settings(Description = "Visible top level windows across every hidden desktop added up.")]
179 int WindowCount { get; }
180 [Settings(Description = "True while the screen is on a hidden desktop and has not been handed back.")]
181 bool IsShowing { get; }
182 [Browser(Description = "Walk every hidden desktop that has windows, the default time each.")]
183 string Peek();
184 [Browser(Description = "Walk every hidden desktop that has windows, this many milliseconds each.")]
185 string Peek(int forMsEach);
186 [Browser(Description = "Put one named desktop on the screen for the default time.")]
187 string Peek(string desktopName);
188 [Browser(Description = "Put the screen back on the desktop a peek took it from. Safe from any thread.")]
189 bool Return();
190 [Browser(Description = "Give up GPAL's handles on every hidden desktop. Closes nothing running on them.")]
191 void CloseAll();
192 }
193
194 #region <BaseBrowserInterfaces>
195 public interface IAllowGoToOrGet : IAllowGoTo, IAllowGet, IAllowToGPALObject<IBrowser>
196 { }
198 { }
199 public interface IAllowBrowserType { [Settings(Description = "Set which browser type to run: Chrome (default), Edge or Firefox.")] IAllowBrowserSettingsOrGoTo WithBrowserType([BrowserType()] BrowserType browserType); }
200
202 {
203 [Settings(Description = "Set which engine to use to automate the browser: OttoMagic, Puppeteer (default) or Selenium.")]
204 IAllowBrowserSettingsOrGoTo WithAutomationEngine(AutomationEngine automationEngine);
205
206 }
207 public interface IAllowDebugPort
208 {
209 [Settings(Description = "Set debug port to use [57005 (0xdead) default]. Specify to reconnect to a browser session using .WithExistingPort. If both port and pipe are set, port is preferred.")]
210 IAllowBrowserSettingsOrGoTo WithUseDebugPort(int debugPort = 0xdead);
211 [Settings(Description = "Use debug pipe for puppeteer commmunications. If both port and pipe are set, port is preferred.")]
212 IAllowBrowserSettingsOrGoTo WithUseDebugPipe(bool trueFalse = false);
213 [Settings(Description = "Drive a browser whose GPALRestAPI is already running, here or on another machine, instead of launching one")]
214 IAllowBrowserSettingsOrGoTo WithRestApiUrl(string restApiUrl);
215 }
216 public interface IAllowExistingBrowser
217 {
218 [Settings(Description = "")]
219 IAllowBrowserActionOrAnySelector WithExistingBrowser(int debugPort = 6565);
220 }
222 {
223 [Settings(Description = "Load images in the page, this can affect layout and object coordinates, if that matters.")]
224 IAllowBrowserSettingsOrGoTo WithLoadImages(bool trueFalse = false);
225 [Settings(Description = "Scroll each scraped element into view as it is read, so the page follows the workflow. For watching a run, not for correctness. Ignored in headless. [false default]")]
226 IAllowBrowserSettingsOrGoTo WithScrollIntoView(bool trueFalse = true);
227 [Settings(Description = "Open PDF files externally, not in the browser. So, download the pdf.")]
228 IAllowBrowserSettingsOrGoTo WithOpenPDFExternally(bool trueFalse = false);
229 [Settings(Description = "Prompt when downloading a file? [true default/false for headless]")]
230 IAllowBrowserSettingsOrGoTo WithPromptForDownload(bool trueFalse = true);
231 [Settings(Description = "Location of the browser driver and where automatically updating the driver will occur. Default is executable directory.")]
232 IAllowBrowserSettingsOrGoTo WithDriverLocation([Directory(Description = "Location of browser driver for this instance. [./ (default)(same dir as exe)]")] string driverPath);
233 [Settings(Description = "Control whether popups are blocked")]
234 IAllowBrowserSettingsOrGoTo WithBlockPopUps(bool trueFalse = true);
235 [Settings(Description = "Use javascript injection to interact with an element")]
236 IAllowBrowserSettingsOrGoTo WithUseStealth(StealthType steathType);
237 [Settings(Description = "Always overwrite a file if it exists")]
238 IAllowBrowserSettingsOrGoTo WithOverwriteExistingFile(bool trueFalse = true);
239 [Settings(Description = "Wait for browser page to finish loading")]
240 IAllowBrowserSettingsOrGoTo WithWaitOnDocumentReady(int timeoutInMs);
241 [Settings(Description = "How long a click waits to see whether it started a navigation. [250 (default)] 0 skips the check")]
242 IAllowBrowserSettingsOrGoTo WithNavigationGrace(int graceInMs);
243 [Settings(Description = "Run the browser on a Win32 desktop object of its own, headful but invisible, so the workflow does not take the screen. Hardware engines cannot reach a desktop nobody is on and step down to the protocol engine of their own family.")]
244 IAllowBrowserSettingsOrGoTo WithHiddenDesktop(bool trueFalse = true);
245 [Settings(Description = "Run the browser on the named Win32 desktop object. Browsers naming the same desktop share it, browsers naming different ones get one each.")]
246 IAllowBrowserSettingsOrGoTo WithHiddenDesktop(string desktopName);
247 [Settings(Description = "To change browser profiles, use this option to specify the data-dir path. If Directory and UserName are both defined, Directory will be used.")]
248 IAllowBrowserSettingsOrGoTo WithProfileDataDirectory(string profilePath);
249 [Settings(Description = "To change browser profiles, use this option to specify the username whose browser data-dir to use. If Directory and UserName are both defined, Directory will be used.")]
250 IAllowBrowserSettingsOrGoTo WithProfileUserName(string profileUserName);
251 [Settings(Description = "The name of the browser profile to use under the data-dir (sometime, might be same result as UserName)")]
252 IAllowBrowserSettingsOrGoTo WithProfileName(string profileName);
253 [Settings(Description = "Set the browser default download directory. Can be overriden with a fully qualified filename. [path/file/]")]
254 IAllowBrowserSettingsOrGoTo WithDownloadLocation(string downloadPat);
255 [Settings(Description = "Use websockets to download for Right Click and Download")]
256 IAllowBrowserSettingsOrGoTo WithUseDirectDownload(bool trueFalse = false);
257 [Settings(Description = "Set the time in seconds to wait for a download to finish before giving up.")]
258 IAllowBrowserSettingsOrGoTo WithDownloadTimeoutInSec(int seconds = 60);
259 [Settings(Description = "Set the HTTP referrer to use when navigating every subsequent Get/Goto. Use empty string to clear.")]
260 IAllowBrowserSettingsOrGoTo WithUseReferrer(string referrer = "");
261 IAllowBrowserSettingsOrGoTo WithUseUserAgent(string userAgent = "");
262 [Settings(Description = "Launch a browser purely to read its real user agent. Off by default, in which case the user agent comes from WithUseUserAgent, then gpal.yaml, then the per-browser template with the installed version filled in")]
263 IAllowBrowserSettingsOrGoTo WithUserAgentFromBrowser(bool userAgentFromBrowser = true);
264 [Settings(Description = "Set whether or not to obey robots.txt (false - default).")]
265 IAllowBrowserSettingsOrGoTo WithObeyRobotsTxt(bool trueFalse = false);
266 [Settings(Description = "Set whether or not to respect robot meta tags noindex/nofollow/none (false - default).")]
267 IAllowBrowserSettingsOrGoTo WithRespectRobotMetaTags(bool trueFalse = false);
268 }
269 public interface IAllowNewTabOrWindow
270 {
271 [Action(Description = "Open url in a new tab")]
272 IAllowBrowserActionOrAnySelector NewTab(GPALUrl url = null);
273 [Action(Description = "Open url in a new window")]
274 IAllowBrowserActionOrAnySelector OpenWindow(GPALUrl url = null);
275 }
277 {
278 // return values
279 // 0 = not handled
280 // 1 = handled
281 // -1 = error
282 [Callback(Description = "GLOBAL based callback if any selector in any UOW is found")]
283 IAllowBrowserSettingsOrGoTo PersistentCallIfFound(Browser.CallIfDelegate CallIfFound);
284 [Callback(Description = "GLOBAL based callback if any selector in any UOW is NOT found")]
285 IAllowBrowserSettingsOrGoTo PersistentCallIfNotFound(Browser.CallIfDelegate CallIfNotFound);
286 [Callback(Description = "Callback when something fails that the workflow can decide about, a navigation that never loaded a page being the case today. Falls through to GPAL.CallOnFail when this browser has none")]
288 [Settings(Description = "Who this browser is, for a site that asks. The credential's WebAuthType decides how it is presented, and it is presented once at the first navigation")]
289 IAllowBrowserSettingsOrGoTo WithCredentials(ICredentials credentials);
290 }
291 public interface IAllowCallBack
292 {
293 // return values
294 // 0 = not handled
295 // 1 = handled
296 // -1 = error
297 [Callback(Description = "UOW based callback if any selector in the UOW is found")]
298 IAllowAfterAnySelector CallIfFound(Browser.CallIfDelegate CallIfFound);
299 [Callback(Description = "UOW based callback if any selector in the UOW is NOT found")]
300 IAllowAfterAnySelector CallIfNotFound(Browser.CallIfDelegate CallIfNotFound);
301 [Callback(Description = "UOW based callback when a row of input is consumed and entered.\nUseful for chaining to another workflow")]
302 IAllowAfterAnySelector CallAfterFillIn(Browser.CallAfterFillInDelegate CallAfterFillIn);
303 }
304 public interface IAllowSizeControl : IAllowToGPALObject<IBrowser>
305 {
306 IAllowAllBrowserAndAllSelector Maximize { [Browser(Description = "Maximize the browser window")] get; }
307 IAllowAllBrowserAndAllSelector Minimize { [Browser(Description = "Minimize the browser window")] get; }
308 // IAllowAllBrowserAndAllSelector Normal { [Browser(Description = "Restore the browser window after fullscreen.")] get; }
309 IAllowAllBrowserAndAllSelector Restore { [Browser(Description = "Restore the browser window from maximize or full-screen.")] get; }
310 IAllowAllBrowserAndAllSelector FullScreen { [Browser(Description = "Put the browser in full-screen mode.")] get; }
311 [Browser(Description = "Set the desired browser window size.")]
312 IAllowAllBrowserAndAllSelector WithWindowSize(System.Drawing.Rectangle windowSize);
313 }
314 public interface IAllowHideElement
315 {
316 [Action(Description = "Hide the found element")]
317 IAllowBrowserActionOrAnySelector Hide(Selector selector = null);
318 }
319 public interface IAllowSetAttributeValue
320 {
338 [Action(Description = "Directly set a DOM attribute (named by the preceding WithAttribute call) to the given value on the found element(s). Does not simulate typing and does not honor GPAL.TypingDelay.")]
340 }
342 {
351 [Action(Description = "Set the value of the element(s) matched by the preceding WithSelector call from the value of the element matched by the given selector.")]
353 }
354 public interface IAllowWithAttribute
355 {
362 [Data(Description = "Names the attribute to set; must be followed by .SetAttribute(value) to specify the value and complete the action.")]
364 }
365 public interface IAllowClicks
366 {
367 [Action(Description = "Left click the found element.")]
369 [Action(Description = "Left click the found element.")]
370 IAllowBrowserActionOrAnySelector LeftClick(Selector selector);
371 [Action(Description = "M iddle click the found element.")]
373 [Action(Description = "Left click the found select menu element.")]
374 IAllowBrowserActionOrAnySelector SelectClick(SelectClickType selectClickType);
375 [Action(Description = "Stealth (Runtime.disable before) Left click the found element.")]
376 IAllowBrowserActionOrAnySelector StealthLeftClick(Selector selector);
377 [Action(Description = "Left click the found element, pressing modifier key (none [default]) while clicking.")]
378 IAllowBrowserActionOrAnySelector LeftClick(ModifierKeys modifierKeys);
379 [Action(Description = "Left click the found element, handling a download dialog after clicking.")]
380 IAllowBrowserActionOrAnySelector LeftClickAndDownload(GPALFile filenames);
381 [Action(Description = "Left click the found element, handling an upload dialog after clicking.")]
382 IAllowBrowserActionOrAnySelector LeftClickAndUpload(GPALFile filenames);
383 [Action(Description = "Left double click the found element, pressing modifier key (none [default]) while clicking.")]
384 IAllowBrowserActionOrAnySelector LeftDoubleClick();
385 [Action(Description = "Right click the found element, pressing modifier key (none [default]) while clicking.")]
386 IAllowBrowserActionOrAnySelector RightClick(Selector selector = null);
387
388 // returns the file name(s) saved to by adding to the ReturnedFilenames list
389 // if not overwriting files, then a timestamp is appended to the filename and returned
390 // if overwriting, the same filename is added to the list
391 // since we can iterate over multiple elements, this could right click and download multiple links, so filenames contains ALL expected filenames to save to
392 [Action(Description = "Save the element (if WithSelector is specified) or page to the GPALFile.")]
393 IAllowBrowserActionOrAnySelector RightClickAndDownload(GPALFile filenames);
394 }
395 public interface IAllowWaitForWindow
396 {
397 [Wait(Description = "After an action is called (ie, LeftClick), wait for a window to open with this name (title)")]
398 IAllowAfterWaitForAndSizeControl WaitForWindow(string windowName);
399 [Wait(Description = "After an action is called (ie, LeftClick), wait for a window to open which name (title) matches the regular expression")]
400 IAllowAfterWaitForAndSizeControl WaitForWindowRegex(string windowNameRegex);
401 [Wait(Description = "The time in seconds to wait for a window to appear before giving up")]
402 IAllowAfterWaitForAndSizeControl WithWaitForWindowTimeout(int waitTimeInSeconds);
403
404 }
405 public interface IAllowFillInFrom
406 {
407 [Data(Description = "Send the specified string using the selector interaction type (selenium/javascript/hardware)")]
408 IAllowBrowserActionOrAnySelector SendString(string textToSend);
409 [Data(Description = "Send a control character specified by the VKCode (GPAL has some defined)")]
410 IAllowBrowserActionOrAnySelector SendKey(byte VKCode);
411 [Data(Description = "Press the modifier key specified (Control/Shift/Alt). NOTE: Be careful with Shift and sending mixed case strings after pressing Shift. Mixed case strings will release the Shift key.")]
412 IAllowBrowserActionOrAnySelector PressModifierKey(ModifierKeys modifierKeys);
413 [Data(Description = "Release the modifier key specified (Control/Shift/Alt) as previously pressed.")]
414 IAllowBrowserActionOrAnySelector ReleaseModifierKey(ModifierKeys modifierKeys);
415
416 [Data(Description = "Fill in [overwrite] text from a string")]
417 IAllowBrowserActionOrAnySelector FillInFrom(string textToUse);
418 [Data(Description = "Append to the end text from a string")]
419 IAllowBrowserActionOrAnySelector AppendFrom(string textToUse);
420 [Data(Description = "Insert text (wherever the cursor is) from a string")]
421 IAllowBrowserActionOrAnySelector InsertFrom(string textToUse);
422
423 [Data(Description = "Fill in [overwrite] text from a file. CSV values per line takenized for each input selector")]
424 IAllowBrowserActionOrAnySelector FillInFrom(GPALFile inputFile);
425 [Data(Description = "Append to the end text from a file. CSV values per line takenized for each input selector")]
426 IAllowBrowserActionOrAnySelector AppendFrom(GPALFile inputFile);
427 [Data(Description = "Insert text (wherever the cursor is) from a file. CSV values per line takenized for each input selector")]
428 IAllowBrowserActionOrAnySelector InsertFrom(GPALFile inputFile);
429
430 [Data(Description = "Fill in [overwrite] text from a database query. Tokenized by each column per input per row")]
431 IAllowBrowserActionOrAnySelector FillInFrom(GPALDatabase inpuDatabase);
432 [Data(Description = "Append to the end text from a database query. Tokenized by each column per input per row")]
433 IAllowBrowserActionOrAnySelector AppendFrom(GPALDatabase inpuDatabase);
434 [Data(Description = "Insert text (wherever the cursor is) from a database query. Tokenized by each column per input per row")]
435 IAllowBrowserActionOrAnySelector InsertFrom(GPALDatabase inpuDatabase);
436 [Data(Description = "Fill in [overwrite] text from a data grid. Tokenized List<List<string>> each string per input per list entry")]
437 IAllowBrowserActionOrAnySelector FillInFrom(IGPALGrid<string> inputGrid);
438 [Data(Description = "Append to the end text from a data grid. Tokenized List<List<string>> each string per input per list entry")]
439 IAllowBrowserActionOrAnySelector AppendFrom(IGPALGrid<string> inputGrid);
440 [Data(Description = "Insert text (wherever the cursor is) from a data grid. Tokenized List<List<string>> each string per input per list entry")]
441 IAllowBrowserActionOrAnySelector InsertFrom(IGPALGrid<string> inputGrid);
442 [Data(Description = "Set the value of an input range element")]
443 IAllowBrowserActionOrAnySelector SetRange(int rangeValue);
444 };
445 public interface IAllowTabActions
446 {
447 [Browser(Description = "Close the current tab [no URL], or the tab with URL")]
448 IAllowBrowserActionOrAnySelector CloseTab(dynamic URLorTabId = null);
449 IAllowBrowserActionOrAnySelector NextTab { [Browser(Description = "Move to the next tab (to the right)")] get; }
450 IAllowBrowserActionOrAnySelector PreviousTab { [Browser(Description = "Move to the previous tab (to the left)")] get; }
451 [Browser(Description = "Go to tab with URL")]
452 IAllowBrowserActionOrAnySelector GoToTab(dynamic URLorTabTuple = null);
453 }
454 public interface IAllowInSelector
455 {
456 [Selector(Description = "Subsequent withselector searches are for elements nested under this element. Nesting is possible.")]
457 IAllowAfterAnySelector InElement(Selector selector);
458 [Selector(Description = "Subsequent withselector searches are for elements nested under this iframe. Nesting is possible.")]
459 IAllowAfterAnySelector InFrame(Selector selector);
460
466 [Selector(Description = "Subsequent selector are for elements in a shadowdom specified by the shadowdom selector. Nesting is possible.")]
468 [Selector(Description = "Reset back to the top level dom document for finding elements")]
469 IAllowAfterAnySelector InMainDom();
470 }
471 public interface IAllowScrolling
472 {
473 [Action(Description = "Use javsacript injection to scroll the specified web element n pixels horizontally")]
474 IAllowBrowserActionOrAnySelector ScrollElementHorizontalByPixels(int scrollAmountInPixels);
475 [Action(Description = "Use javascript injection to scroll the specified web element n pixels vertically")]
476 IAllowBrowserActionOrAnySelector ScrollElementVerticalByPixels(int scrollAmountInPixels);
477 }
478 public interface IAllowWindowScrollBy
479 {
480 [Browser(Description = "Scroll the browser window horizontally by scrollAmount pixels")]
481 IAllowBrowserActionOrAnySelector ScrollWindowByHorizontal(int scrollAmount);
482 [Browser(Description = "Scroll the browser window veritcally by scrollAmount pixels")]
483 IAllowBrowserActionOrAnySelector ScrollWindowByVertical(int scrollAmount);
484 }
485 public interface IAllowWindowActions
486 {
487 [Browser(Description = "Close the current window [no URL], or the window with URL")]
488 IAllowBrowserActionOrAnySelector CloseWindow(dynamic URLorId = null);
489 IAllowBrowserActionOrAnySelector NextWindow { [Browser(Description = "Move to the next window (to the right)")] get; }
490 IAllowBrowserActionOrAnySelector PreviousWindow { [Browser(Description = "Move to the previous window (to the left)")] get; }
491 [Browser(Description = "Go to window with URL")]
492 IAllowBrowserActionOrAnySelector GoToWindow(dynamic URLorId = null);
493 }
494 public interface IAllowPageControl
495 {
496 IAllowBrowserActionOrAnySelector Back { [Browser(Description = "Move back one entry in the browser history")] get; }
497 IAllowBrowserActionOrAnySelector Forward { [Browser(Description = "Move forward one entry in the browser history")] get; }
498 IAllowBrowserActionOrAnySelector PageDown { [Browser(Description = "Scroll one page down")] get; }
499 IAllowBrowserActionOrAnySelector PageEnd { [Browser(Description = "Scroll to page bottom")] get; }
500 IAllowBrowserActionOrAnySelector PageTop { [Browser(Description = "Scroll to page top")] get; }
501 IAllowBrowserActionOrAnySelector PageUp { [Browser(Description = "Scroll one page up")] get; }
502 IAllowBrowserActionOrAnySelector Refresh { [Browser(Description = "Refresh the current page")] get; }
503 }
504 public interface IAllowExecuteJavaScript
505 {
506 [Browser(Description = "Execute the supplied javascript in the browser and return an integer in browser.JavaScriptResultObj")]
507 IAllowBrowserActionOrAnySelector ExecuteJavaScriptObj(string javascript);
508 [Browser(Description = "Execute the supplied javascript in the browser and return an integer in browser.JavaScriptResultStr")]
509 IAllowBrowserActionOrAnySelector ExecuteJavaScriptStr(string javascript);
510 }
511 public interface IAllowDialogHandling
512 {
513 [Browser(Description = "Answer the alert, confirm and prompt dialogs the page raises, instead of letting them open and block. True accepts (OK, and confirm returns true), false dismisses (Cancel, and confirm returns false). Set it before the browser launches.")]
514 IAllowBrowserActionOrAnySelector WithDialogsAccepted(bool accept);
515 [Browser(Description = "What a prompt hands back when dialogs are accepted. Not available on Selenium, where the driver answers the dialog itself.")]
516 IAllowBrowserActionOrAnySelector WithDialogText(string text);
517 [Browser(Description = "Stop answering dialogs, so they open and block again. Different from WithDialogsAccepted(false), which answers Cancel.")]
518 IAllowBrowserActionOrAnySelector ClearDialogHandling();
519 }
521 {
522 [Browser(Description = "Where this browser's window is and how big it is, in screen coordinates, chrome included. Answered by whichever engine is driving, so a workflow does not have to know which one that is.")]
523 IAllowBrowserActionOrAnySelector GetWindowRectangle(out System.Drawing.Rectangle window);
524 }
525 public interface IAllowInjectScript
526 {
527 [Browser(Description = "Inject a script (raw JS string, or GPALFile - if multiple files are specified, all are loaded and injected as separate scripts) to run on every new document load. Callable before the first .GoTo()/.Get() (active from the first page load) or at any later point (applies to subsequent navigations). Persists until .ClearInjectedScripts() is called.")]
528 IAllowBrowserActionOrAnySelector InjectScript(string script);
529 [Browser(Description = "Inject script(s) loaded from a GPALFile - if multiple filenames are specified (e.g. via wildcard), all are loaded and injected as separate scripts.")]
530 IAllowBrowserActionOrAnySelector InjectScript(GPALFile scriptFile);
531 [Browser(Description = "Remove all scripts previously registered via InjectScript.")]
532 IAllowBrowserActionOrAnySelector ClearInjectedScripts();
533 }
535 {
536 [Settings(Description = "Wait for browser network activity to idles. Defauilt is 0 connections.")]
537 IAllowBrowserSettingsOrGoTo WithWaitOnIdleConnection(bool trueFalse = true);
538 [Settings(Description = "Timeout to wait for network idle = true. Defauilt is 500 ms.")]
539 IAllowNetworkIdleSettings WithNetworkIdleTimeoutMs(int networkIdleTimeoutMs = 500);
540 [Settings(Description = "Timeout to wait for network idle = true. Defauilt is 500 ms.")]
541 IAllowNetworkIdleSettings WithNetworkIdleMaxConnections(int maxConnections = 0);
542 [Settings(Description = "Duration to maintain network stats before pruning old data. Default is 10 seconds (10_000 ms).")]
543 IAllowNetworkIdleSettings WithNetworkIdlePruneMs(int networkIdlePruneMs = 10_000);
544
545 }
546 #endregion <BaseInterfaces>
547
548 #region <Atoms>
549 public interface IAllowToGPALObject<TResult>
550 {
551 [Fluent(Description = "Ends a declaration or workflow, returning a GPAL object which can be assigned. Use instead of an explicit cast. [ Selector mySel = GPAL.Selector.WithCSS(css).ToGPALObject() ]")]
552 TResult ToGPALObject();
553 }
554 public interface IAllowWithPersistentSelector { [Settings()] IAllowSelectorInFrameBrowserSettingsOrGoto WithPersistentSelector(Selector persistentSelector); }
556 public interface IAllowWithSelector : IAllowWithData { [Selector(Description = "Add a selector to this UOW")] IAllowAfterAnySelector WithSelector(Selector selector); }
557 public interface IAllowWithData
558 {
559 [Selector(Description = "Add literal data to a grid when using .GetGrid")] IAllowAfterAnySelector WithSelector(string literalData);
560 [Selector(Description = "Add literal data to a grid by invoking this function when using .GetGrid")] IAllowAfterAnySelector WithSelector(Func<string> dataFunction);
561 }
562 public interface IAllowSiteMapOperations
563 {
564 [Action("Get the current page source")]
565 IAllowBrowserActionOrAnySelector GetPageSource(out string sitemapXML);
566 [Action("Carry on without the browser: hand back a RESTClient holding this browser's origin, cookies, user agent, accept language and credential")]
567 IAllowBrowserActionOrAnySelector ContinueAsRESTClient(out IRESTClient client);
568 [Action("Get the raw sitemap XML")]
569 IAllowBrowserActionOrAnySelector GetSiteMap(out string sitemapXML);
570 [Action("Get the sitemap URLs as a List<string>")]
571 IAllowBrowserActionOrAnySelector GetSiteMapUrls(out List<string> sitemapXML);
572 [Action("Save the sitemap URLs to a file, format chosen by the file extension")]
573 IAllowBrowserActionOrAnySelector SaveSiteMapUrls(GPALFile sitemapUrlsFile);
574 [Action("Clear cached sitemap / LLM digest / hydration results, forcing the next Get/Save to refetch")]
575 IAllowBrowserActionOrAnySelector ClearResultCache();
576 [Action("Get the current page source as an LLM digest")]
577 IAllowBrowserActionOrAnySelector GetLLMDigest(out LLMDigestResult digestResult, string ruleSetName = null);
578 [Action("Save to file, the current page source as an LLM digest")]
579 IAllowBrowserActionOrAnySelector SaveLLMDigest(GPALFile llmDigestFile, string ruleSetName = null);
580 [Action("Get the current page next.js hydrated data")]
581 IAllowBrowserActionOrAnySelector GetHydratedData(out NextJsHydrationResult hydrationResult);
582 [Action("Save to file, the current page next.js hydrated data")]
583 IAllowBrowserActionOrAnySelector SaveHydratedData(GPALFile hydrationFile);
584 }
585 public interface IAllowStorageAction
586 {
587 [Action("Run the get storage actions for storageType")]
588 IAllowStorageOutData RunGet(WebsiteStorageType storageType);
589 [Action("Run the set storage actions for storageType")]
590 IAllowBrowserActionOrAnySelector RunSet(WebsiteStorageType storageType);
591 [Action("Run the delete storage actions for storageType")]
592 IAllowBrowserActionOrAnySelector RunDelete(WebsiteStorageType storageType);
593 }
595 {
596 [Browser(Description = "The domain for the storage action")]
597 IAllowStorageOptions WithStorageDomain(string domain);
598 [Browser(Description = "The path for the storage action")]
599 IAllowStorageOptions WithStoragePath(string path);
600 [Browser(Description = "The key for the storage action")]
601 IAllowStorageOptions WithStorageKey(string key);
602 [Browser(Description = "The store name for the indexedDb action")]
603 IAllowStorageOptions WithStorageStoreName(string storeName);
604 [Browser(Description = "The user defined filter to help select wildcard storage actions")]
605 IAllowStorageOptions WithUserDefinedFilter(string userDefined);
606
607 }
608 public interface IAllowStorageData { [Browser(Description = "The data for storage set operations")] IAllowStorageOptions WithStorageData(string data); }
609 public interface IAllowStorageOutData { [Browser(Description = "The data for storage get operations")] IAllowBrowserActionOrAnySelector GetStorageData(out string data); }
610 public interface IAllowGoTo { [Browser(Description = "Go to the specified URL")] IAllowBrowserActionOrAnySelector GoTo([URL()] GPALUrl URL); }
611 public interface IAllowGet { [Browser(Description = "Navigate to the URL headless, launching a headless browser when none is open. Same navigation as GoTo, with the headless download options set first")] IAllowBrowserActionOrAnySelector Get([URL()] GPALUrl URL); }
612 public interface IAllowClose { [Browser(Description = "Close the current browser session. True [default] to kill web drivers running.")] void Close(bool killWebDrivers = false); }
613 public interface IAllowFocus { [Action(Description = "Bring the current element (specified by .WithSelector) into focus.")] IAllowBrowserActionOrAnySelector Focus(Selector selector = null); }
614 public interface IAllowHover { [Action(Description = "Hover the mouse over the current element (specified by .WithSelector). [hardware emulation (see .WithSimulateMouse)]")] IAllowBrowserActionOrAnySelector Hover(Selector selector = null); }
615 public interface IAllowMoveTo { [Action(Description = "Move the cursor (focus) to the current element (specified by .WithSelector).")] IAllowBrowserActionOrAnySelector MoveTo(Selector selector = null); }
616 public interface IAllowWithNextPageButton { [Data(Description = "When retrieving multiple pages of results, this is the button to click to get more results.")] IAllowWithPagesAndGridActions WithNextPageButton(Selector selector); }
617 public interface IAllowWithInfiniteScroll { IAllowWithPagesAndGridActions WithInfiniteScroll { [Data(Description = "When retrieving multiple pages of results, this imdocates scroll to page bottom to get more results.")] get; } }
618 public interface IAllowWithPages { [Data(Description = "Number of result pages to retrieve when retrieving multiple pages of results.")] IAllowGetGridAndFillInFrom WithPages(int numberOfPages); }
619 public interface IAllowWithTokensFrom
620 {
621 [Data(Description = "Values .Fetch drops into its request's numbered tokens, one row per set of requests. Column 0 fills {0}, column 1 fills {1}, and so on")]
622 IAllowWithPagesAndFetch WithTokensFrom(IGPALGrid<string> inputGrid);
623 [Data(Description = "Values .Fetch drops into its request's numbered tokens, from a file. CSV values per line, one line per set of requests")]
624 IAllowWithPagesAndFetch WithTokensFrom(GPALFile inputFile);
625 [Data(Description = "Values .Fetch drops into its request's numbered tokens, from a database query. One column per token, one row per set of requests")]
626 IAllowWithPagesAndFetch WithTokensFrom(GPALDatabase inputDatabase);
627 [Data(Description = "Values .Fetch drops into its request's numbered tokens, as a single row of comma separated values")]
628 IAllowWithPagesAndFetch WithTokensFrom(string tokens);
629 }
630 public interface IAllowGetGrid { [Data(Description = "Retrieve data and add it into this GPALGrid. Pass a grid configured with .WithDedupeData(true) to skip duplicate rows. GPAL keeps one internally for a workflow if you pass null.")] IAllowWithHeaderOrFileActions GetGrid(ref IGPALGrid<string> returnGrid); }
631 public interface IAllowGetElements { [Data(Description = "Find elements for all selectors in this UOW and return them as a unified List<GPALElement>. Results are also available per-selector via selector.WebSelectorFoundResults.")] IAllowBrowserActionOrAnySelector GetElements(out List<GPALElement> elements); }
632 public interface IAllowWithHeader { [Data(Description = "Column header for exported data. If a selector is not given a new (.WithName), use this. Or use this instead of the name when used on a Selector.")] IAllowWithHeaderOrFileActions WithHeader(string header); }
633 public interface IAllowWithAllThatMatch { [Data(Description = "How many items per page to retrieve OR total items to retrieve. Defaults to int.MaxValue, get all items that match. If less than returns on a page, retrieve only rowCount, rows of results per page. If greater than the number of results on a page, this is the total number of results to return.")] IAllowAfterAnySelectorExceptWithAll WithAllThatMatch(int rowCount = int.MaxValue); }
634 public interface IAllowWithHardware { IAllowAfterAnySelector WithHardware { [Settings(Description = "Use hardwre emulation to interact with this element")] get; } }
635 public interface IAllowWithJavaScript { IAllowAfterAnySelector WithJavaScript { [Settings(Description = "Use javascript injection to interact with this element")] get; } }
636 public interface IAllowWaitFor
637 {
638 [Wait(Description = "IF after an action is called, this is a sleep timer. If used after adding selectors (.WithSelector) [before calling an action], this is the time to wait to find elements for .WithSelectors before continuing the workflow (can cause to invoke CallIfNotFound handler)")]
639 IAllowAfterWaitFor WaitFor(WaitTime waitForTimeInMs);
640 [Wait(Description = "Wait for the Selector before proceeding with the workflow. Use WaitFor(timeInMs) or use the default of three [3] seconds. Similar to .WithSelector.WaitFor.Action (can cause to invoke CallIfNotFound handler)")]
641 IAllowAfterWaitFor WaitFor(Selector waitForSelector);
642 [Wait(Description = "Wait for the element(s) defined using .WithSelector to enter the specified state.")]
643 IAllowAfterWaitFor WaitFor(ElementState elementState);
644 }
645 public interface IAllowWithGridToSave { [Data(Description = "Data GPALGrid used to save results, could be created in another/sub-workflow")] IAllowWithHeaderOrFileActions WithGridToSave(IGPALGrid<string> filename); }
646 public interface IAllowStartWorkflow { [Fluent(Description = "Start the workflow if no action is used to start the workflow. Perhaps your logic is in the CallIf handlers, so this will kick off finding the selector elements, thus calling Found/NotFound handlers")] IAllowBrowserActionOrAnySelector StartWorkflow(); }
647 public interface IAllowDragAndDrop
648 {
649 [Fluent(Description = "Perform a drag-and-drop operation. OffsetX/Y is the grab point, DeltaX/DeltaY is the drop offset. Uses native drag events for the current automation engine (Selenium Actions, CDP mouse events, or OttoMagic in-page events); falls back to smoothed hardware mouse emulation for image-matched/remote-desktop elements")]
650 IAllowBrowserActionOrAnySelector DragAndDrop(Selector selector = null);
651 [Fluent(Description = "Perform a drag-and-drop operation while pressing a modifier key. OffsetX/Y is the grab point, DeltaX/DeltaY is the drop offset. Uses native drag events for the current automation engine (Selenium Actions, CDP mouse events, or OttoMagic in-page events); falls back to smoothed hardware mouse emulation for image-matched/remote-desktop elements")]
652 IAllowBrowserActionOrAnySelector DragAndDrop(ModifierKeys modifierKeys);
653 }
654 public interface IAllowPrintDomElement
655 {
656 [Fluent(Description = "Print the element defined by .withselector/page (if no selector set) to PDF file.")]
657 IAllowBrowserActionOrAnySelector PrintToPDF(GPALFile gpalFile);
658 [Fluent(Description = "Print orientation for PrintToPDF - use before calling PrintToPDF")]
659 IAllowBrowserActionOrAnySelector WithPageOrientation(PageOrientation pageOrientation);
660 }
661 public interface IAllowCasting
662 {
663 [Fluent(Description = "Cast the current tab to the specified device")]
664 IAllowBrowserActionOrAnySelector CastTab(string deviceNameOrId);
665 [Fluent(Description = "Cast the desktop to the specified device")]
666 IAllowBrowserActionOrAnySelector CastDesktop(string deviceNameOrId);
667 [Fluent(Description = "Stop casting to device")]
669 }
670 #endregion <Atoms>
671
672 #region <DerivedInterfaces>
673 // An emergent rule of thumb...
674 // If the word "Or" appears more than once, invent an umbrella term.
675 // And then derive stuff... from the derived stuff.
676 // Because nobody wants to look at IAllowGoToOrGlobalWaitOnDocumentReadyOrClose.
677 // .WithTokensFrom and .WithPages both feed .Fetch, so either can come first
678 public interface IAllowWithPagesAndFetch
681 { }
690 public interface IAllowAnySelector
693 { }
698
706
710 public interface IAllowCallTemplate
712 {
713 [Action(Description = "Wait for the page to make a matching call and hand it back as a request ready to issue")]
714 IAllowBrowserActionOrAnySelector CaptureCallTemplate(out GPALRequest template);
715 }
716
744 public interface IAllowFetch
745 {
746 [Fluent(Description = "Issue an API request from inside the page, so it carries the session the browser already earned: its cookies, TLS fingerprint, header order and any anti-bot clearance. Honors .WithPages and .WithTokensFrom. The response bodies are handed back with .SaveTo(ref string)")]
748 [Action(Description = "Record what the page asks for, so an endpoint can be read off a site")]
749 IAllowBrowserActionOrAnySelector CaptureCalls(bool capture = true);
750 [Action(Description = "Record what the page asks for and hand back everything recorded so far")]
751 IAllowBrowserActionOrAnySelector CaptureCalls(out List<GPALCall> calls);
752 [Action(Description = "Forget everything recorded so far, so what comes next is what happens next")]
753 IAllowBrowserActionOrAnySelector ClearCapturedCalls();
754 [Settings(Description = "Only record calls whose url holds this")]
755 IAllowCallTemplate WithCallFilter(string urlFragment);
756 }
804 // NOTE: Add to BELOW LIST what is added here
822 // NOTE: Add to this list what is added above
859 // , IAllowBrowserActionOrAnySelector
860 { }
861 #endregion <DerivedInterfaces>
862 #region Workflow Interfaces
863 public interface IAllowRun
864 {
865 [Workflow(Description = "Runs the workflows added to this browser, in the order they were added.")]
867 }
869 {
870 [Workflow(Description = "Executes the workflow while the predicate returns true.")]
871 IAllowBrowserActionOrAnySelector While(Func<Browser, bool> predicate);
872
873 [Workflow(Description = "Executes the workflow until the specified selector finds at least one element.")]
875
876 [Workflow(Description = "Executes the workflow until the predicate returns true.")]
877 IAllowBrowserActionOrAnySelector Until(Func<Browser, bool> predicate);
878
879 [Workflow(Description = "Sets the timeout in milliseconds for While or Until loops.")]
880 IAllowWorkflowExecution WhileLoopTimeout(int timeoutMs);
881
882 [Workflow(Description = "Sets the maximum number of iterations for While or Until loops.")]
883 IAllowWorkflowExecution WhileLoopMaxIterations(int maxIterations);
884 }
885 public interface IAllowScheduledWorkflow
886 {
887 [Workflow(Description = "Adds a workflow to be scheduled. It builds and owns whatever it drives.")]
888 IAllowScheduledWorkflowExecution WithWorkflow(Action workflow);
889 }
891 {
892 [Settings(Description = "How many workflows may be in flight at once. One, the default, runs them one after another.")]
893 IAllowScheduledWorkflowExecution WithMaxAtOnce(int howMany);
894 [Settings(Description = "The least time between two workflows starting. [250ms (default)] 0 starts them together.")]
895 IAllowScheduledWorkflowExecution WithStaggerStart(int delayInMs);
896 [Settings(Description = "How long to wait for them all before giving up and reporting the unfinished ones as failed. [no limit (default)]")]
897 IAllowScheduledWorkflowExecution WithTimeout(int timeoutInMs);
898 [Workflow(Description = "Runs every workflow added and waits for them all.")]
900 [Workflow(Description = "Runs every workflow added and hands back what happened to each.")]
901 IAllowScheduledWorkflowExecution Run(out List<WorkflowRun> runs);
902 }
903 public interface IAllowWorkflow
904 {
905 [Workflow(Description = "Defines a workflow to be executed repeatedly based on While or Until conditions.")]
906 IAllowWorkflowExecution WithWorkflow(Action<IBrowser> workflow);
907 }
908 #endregion Workflow Interfaces
909 #endregion <BrowserInterfaces>
910 #region <Element Assistant Interfaces>
915 public interface IAllowElementActions
916 {
917 [Action(Description = "Left click the specified element, pressing modifier key (none [default]) while clicking.")]
918 IAllowElementSettingsAndActions LeftClick(IGPALElement webElement);
919 [Action(Description = "Left click the specified element.")]
921 [Action(Description = "Left click the specified element, pressing modifier key (none [default]) while clicking.")]
922 IAllowElementSettingsAndActions LeftClick(ModifierKeys modifierKeys);
923 [Action(Description = "Left double click the specified element, pressing modifier key (none [default]) while clicking.")]
924 IAllowElementSettingsAndActions LeftDoubleClick(IGPALElement webElement);
925 [Action(Description = "M iddle click the found element.")]
927 [Action(Description = "Right click the specified element, pressing modifier key (none [default]) while clicking.")]
928 IAllowElementSettingsAndActions RightClick(IGPALElement webElement);
929 [Data(Description = "Fill in [overwrite] text from a string")]
930 IAllowElementSettingsAndActions FillInFrom(string textToUse);
931 [Data(Description = "Insert text (wherever the cursor is) from a string")]
932 IAllowElementSettingsAndActions InsertFrom(string textToUse);
933 [Data(Description = "Append to the end text from a string")]
934 IAllowElementSettingsAndActions AppendFrom(string textToUse);
935 [Data(Description = "Send a control character specified by the VKCode (GPAL has some defined)")]
936 IAllowElementSettingsAndActions SendKey(byte VKCode);
937 [Data(Description = "Send the specified string using the selector interaction type (selenium/javascript/hardware)")]
938 IAllowElementSettingsAndActions SendString(string textToSend);
939 [Data(Description = "Press the modifier key specified (Control/Shift/Alt). NOTE: Be careful with Shift and sending mixed case strings after pressing Shift. Mixed case strings will release the Shift key.")]
940 IAllowElementSettingsAndActions PressModifierKey(ModifierKeys modifierKeys);
941 [Data(Description = "Release the modifier key specified (Control/Shift/Alt) as previously pressed.")]
942 IAllowElementSettingsAndActions ReleaseModifierKey(ModifierKeys modifierKeys);
943 [Action(Description = "Use javascript injection to scroll the specified web element n pixels horizontally")]
944 IAllowElementSettingsAndActions ScrollHorizontalPixels(int scrollAmount);
945 [Action(Description = "Use javascript injection to scroll the specified web element n pixels vertically")]
946 IAllowElementSettingsAndActions ScrollVerticalPixels(int scrollAmount);
947 }
948 public interface IAllowElementSetting : IAllowToGPALObject<ElementAssistant>
949 {
950 [ElementAssitant(Description = "Declare the element to interact with using the ElementAssistant")]
952 IAllowElementSettingsAndActions WithJavaScript { [Settings(Description = "Use javascript injection to interact with this element")] get; }
953 IAllowElementSettingsAndActions WithHardware { [Settings(Description = "Use hardwre emulation to interact with this element")] get; }
954 }
955
956 #endregion <\Element Interfaces>
957 #region <File Interface>
958 public interface IAllowFileActions
959 {
960 // One save/append syntax. Output format and delimiter come from the GPALFile: its extension
961 // (.csv, .tsv/.txt, .xlsx, .json, .xml, .yaml, ...) or its explicit .WithDelimiter settings.
962 [File(Description = "Save the retrieved grid. Output format and delimiter are determined by the GPALFile (its extension, or explicit file settings).")]
964 [File(Description = "Append the retrieved grid. Output format and delimiter are determined by the GPALFile (its extension, or explicit file settings).")]
966 [File(Description = "Hand back what .Fetch retrieved, as a JSON array holding one response body per page requested.")]
967 IAllowBrowserActionOrAnySelector SaveTo(ref string data);
968 }
969 #endregion
970 #region Graphics Interface
971 public interface IAllowScreenshot
972 {
973 [GPAL(Description = "Capture a screenshot")]
974 IAllowGraphicSettings CaptureScreen(object ApplicationOrBrowser = null);
975
976 }
977 // NOTE: TODO: might these be used in Convertor class?
978 public interface IAllowGraphicSettings
979 {
980 [GPAL(Description = "Save to BASE64 string")]
981 IAllowGraphicSettings ToBase64String(out string base64String);
982 IAllowGraphicSettings ToBitmap(out Bitmap base64String);
983 [File(Description = "Save to file (overwrite)")]
984 IAllowGraphicSettings SaveTo(GPALFile File);
985
986 }
987 public interface IImageHelper : IAllowGraphicSettings, IAllowScreenshot, IAllowToGPALObject<IImageHelper>
988 {
989
990 }
991 #endregion Graphics Interface
992 #region MagicHelper
993 public interface IMagicHelper
994 {
995 // CalculateHash, GetFullUrl, GetRandomStarWarsQuery and LaunchBrowser are static on MagicHelper: they need no
996 // browser, so they must not require one to exist. Reaching them through an instance did
997 void Back();
998 string CaptureVisibleTab();
999 string CheckNetworkIdle(int? maxConnections = null, int? timeoutMs = null, int? pruneMs = null);
1000 TabTuple CloseTab(dynamic URLorTabId = null);
1001 bool DeleteStorage(WebsiteStorageType storageType, bool deleteAcrossOrigins = false, string domain = null, string path = null, string key = null, string storeName = null);
1002 void Forward();
1003 void FullScreen();
1004 string Get(GPALUrl URL); // NOTE: CAVEAT: not sure this makes sense, goto will be the same action on the browser, how it is Launched makes it headless...
1005 string GetContentAndCss(string elementId);
1006 Dictionary<string, object> GetCssAttributes(string elementId);
1007 Dictionary<string, object> GetDomAttributes(string elementId);
1008 Dictionary<string, object> GetDomProperties(string elementId);
1009 string GetCurrentUrl();
1010 string GetReadyStatus(string sessionToken);
1011 GPALElement GetShadowRoot(string Css);
1012 string GetStorage(WebsiteStorageType storageType, string domain = null, string path = null, string key = null, string storeName = null);
1013 TabTuple GoTo(GPALUrl URL);
1014 TabTuple GotoTab(dynamic URLorTabId);
1015 System.Drawing.Rectangle GetWindowRectangle();
1016 void SwitchToElement(string elementId); // in element and in iframe are the same thing
1017 void InFrame(string elementId); // in element and in iframe are the same thing
1018 void Minimize();
1019 void Maximize();
1020 void MoveTo(string elementiId);
1021 void Normal();
1022 TabTuple NewTab(GPALUrl URL = null);
1023 TabTuple NextTab();
1024 int TabCount();
1025 void OverrideReferrer(string referrer);
1026 void SetUserAgent(string userAgent);
1027 void PageDown();
1028 void PageEnd();
1029 void PageTop();
1030 void PageUp();
1031 void PressModifierKey(ModifierKeys modifierKeys);
1032 TabTuple PreviousTab();
1033 void Refresh();
1034 void ReleaseModifierKey(ModifierKeys modifierKeys);
1035 void Restore();
1036 void ScrollWindowByHorizontal(int pixels);
1037 void ScrollWindowByVertical(int pixels);
1038 void SetRange(string elementId, int rangeValue);
1039 bool SetStorage(WebsiteStorageType storageType, string data, string domain = null, string path = null, string key = null, string storeName = null);
1040 void StealthOverrideReferrer();
1041 void WithDownloadFile(string downloadPath);
1042 void Focus(string elementId);
1043 void FireChangeEvent(string elementId);
1044 void ScrollIntoView(string elementId);
1045 void ScrollElement(string elementId, int hPixels, int vPixels);
1046 string GetElementAttributeHash(string elementId);
1047 string GetPageSource();
1048 GPALElement GetParentNode(string elementId);
1049 string GetAttribute(string elementId, string attribute);
1050 void SetAttribute(string elementId, string attribute, string value);
1051 void SetValueFromElement(string srcSelector, string destElementId);
1052 void LeftClick(string elementId);
1053 void LeftDoubleClick(string elementId);
1054 void MiddleClick(string elementId);
1055 void RightClick(string elementId);
1056 void SelectClick(string elementId, dynamic indexOrValue);
1057 bool IsVisibleInViewport(string elementId);
1058 bool IsEndOfPage();
1059 void Hover(string elementId);
1060 void DragAndDrop(string elementId, int deltaX, int deltaY, int offsetX = 0, int offsetY = 0);
1061 int WindowInnerHeight();
1062 int WindowInnerWidth();
1063 int WindowOuterHeight();
1064 int WindowOuterWidth();
1065 string Fetch(string url, string method = null, string body = null, string contentType = null, string[] headers = null, bool asBytes = false);
1066 int WindowPageOffsetX();
1067 int WindowPageOffsetY();
1068 System.Drawing.Rectangle GetBoundingClientRect(string elementId);
1069 void HideElement(string elementId);
1070 void InjectScript(string script);
1071 void ClearInjectedScripts();
1072 bool IsClickAble(string elementId);
1073 void ClearReferrer();
1074 GPALElement Evaluate(string xpath);
1075 List<GPALElement> EvaluateAll(string xpath);
1076 GPALElement EvaluatePersistent(string xpath);
1077 List<GPALElement> EvaluateAllPersistent(string xpath);
1078 string GetLanguages();
1079 string GetUserAgent();
1080 List<GPALElement> GetOptions(string elementId);
1081 void FillInAppend(string elementId, string text);
1082 void FillInInsert(string elementId, string text);
1083 void FillInOverwrite(string elementId, string text);
1084 void LeftClickAndDownload(string elementId, string filenameAndPath);
1085 void LeftClickAndUpload(string elementId, string filenameAndPath);
1086 void LeftClickAndUpload(string elementId, GPALFile filenamesAndPaths);
1087 GPALElement QueryPersistentSelector(string css);
1088 List<GPALElement> QueryPersistentSelectors(string css);
1089 GPALElement QuerySelector(string css);
1090 List<GPALElement> QuerySelectors(string css);
1091 void ScrollWindow(int hPixels, int vPixels);
1092 void SendKey(byte vkcode);
1093 void SendString(string text, int delayMs = 0);
1094 void SubmitForm(string elementId);
1095 void SwitchToDefaultContent();
1096 // void SwitchToFrame(string elementId); // there is no switch to frame, ottomagic runs in all frames
1097 void SwitchToShadowRoot(string elementId);
1098 string GetBrowserSettings();
1099 string GetGpalSettings();
1100 string GetSettings();
1101 string GetWorkflow();
1102 // Process LaunchBrowser(BrowserSettings browserSettings, string URL = "https://google.com", List<string> additionalArguments = null);
1103 bool TopBrowser(Process process);
1104 public WindowTuple OpenWindow(GPALUrl url = null);
1105 public WindowTuple GoToWindow(dynamic urlOrId);
1106 public WindowTuple CloseWindow(dynamic urlOrId);
1107 [Browser(Description = "Move to the next window (to the right)")]
1108 public WindowTuple NextWindow();
1109 [Browser(Description = "Move to the previous window (to the left)")]
1110 public WindowTuple PreviousWindow();
1111 public WindowTuple GetCurrentWindow();
1112 int WindowScreenLeft();
1113 int WindowScreenTop();
1114 }
1115 #endregion MagicHelper
1116 #region Google Sheets
1117 public interface IAllowSpreadsheetSelection : IAllowToGPALObject<IGoogleSheets>
1118 {
1119 IAllowSheetSelection WithSpreadsheet(string spreadsheetIdOrTitle);
1120 }
1121
1122 public interface IAllowSheetSelection : IAllowDataOperations, IAllowSheetOperations, IAllowToGPALObject<IGoogleSheets>
1123 {
1124 IAllowInDataOperations WithSheet(object sheetNameOrId);
1125 IAllowSheetSelection ListSheets(out IEnumerable<(string name, int sheetId)> sheets);
1126 IAllowSheetSelection SetSpreadsheetTitle(string title);
1127 }
1128
1130 {
1131 IAllowSheetSelection SetSheetName(string sheetName);
1132 IAllowDataOperations WithReadRange(string range);
1133 IAllowDataOperations WithData(IGPALGrid<string> data);
1134 IAllowFormatSettings WithFormatType(FormatType formatType);
1135 }
1136
1138 {
1139 IAllowDataOperations AppendToCell(string cell);
1140 IAllowDataOperations PrependToCell(string cell);
1141 IAllowSheetOperations WithWriteRange(string range);
1142 IAllowDataOperations CalculateSum(out string result);
1143 IAllowDataOperations CalculateCount(out string result);
1144 }
1145
1147 {
1148 IAllowSheetSelection DeleteSheet(object sheetNameOrId);
1149 IAllowDataOperations WriteToSheet(object sheetNameOrId);
1150 }
1151
1152 public interface IAllowInsertSettings
1153 {
1154 IAllowInsertSettings WithInsertPosition(int position);
1155 IAllowInsertSettings WithInsertSeparator(string separator);
1156 IAllowDataOperations InsertAtCell(string cell);
1157 }
1158
1159 public interface IAllowFormatSettings
1160 {
1161 IAllowFormatRange WithFormatValue(object formatValue);
1162 IAllowFormatRange WithAlignmentFormatValue(HorizontalAlignmentType alignment);
1163 IAllowFormatRange WithAlignmentFormatValue(VerticalAlignmentType alignment);
1164 IAllowFormatRange WithNumberFormatValue(NumberFormatType numberFormat);
1165 IAllowFormatRange WithTextRotationFormatValue(TextRotationType rotation);
1166 IAllowFormatRange WithColorFormatValue(Color color);
1167 }
1168 public interface IAllowFormatRange
1169 {
1170 IAllowInDataOperations FormatRange(string range);
1171 }
1173 {
1174 IAllowTriggerSettings WithTriggerFunction(string functionName);
1175
1176 }
1177 public interface IAllowTriggerSettings : IAllowWithTriggerFunction, IAllowToGPALObject<IGoogleSheets>
1178 {
1179 IAllowTriggerSettings WithTriggerSchedule(TriggerScheduleType schedule);
1180 IAllowDataOperations CreateTrigger(GoogleTriggerType triggerType);
1181 }
1182 public interface IAllowScriptOperations : IAllowToGPALObject<IGoogleSheets>
1183 {
1184 IAllowScriptOperations WithProjectId(string projectId);
1185 IAllowScriptOperations WithScriptName(string scriptName);
1186 IAllowScriptOperations WithScriptAccess(ScriptAccessType access);
1187 IAllowScriptOperations WithExecuteAs(ExecuteAsType executeAs);
1188 IAllowScriptOperations WithDeploymentDescription(string description);
1189 IAllowScriptOperations WithVersionNumber(int versionNumber);
1190 IAllowDeployWebApp UploadScript(string scriptContent);
1191 IAllowDeployWebApp UploadScript(GPALFile scriptFile);
1192 }
1194 {
1195 IAllowDataOperations DeployScriptAsWebApp(out string webAppUrl);
1196 }
1198 {
1199 IAllowSheetSelection SaveTo(out IGPALGrid<string> gPalGrid);
1200 IAllowSheetSelection SaveTo(GPALFile gPALFile);
1201 }
1204 {
1205 IAllowSpreadsheetSelection WithCredentials(ICredentials credentials);
1206 [Settings(Description = "Drive sheets through an Apps Script web app deployed by hand, instead of the Sheets API. Takes the deployment url and needs no credentials.")]
1207 IAllowSpreadsheetSelection WithWebAppUrl(string webAppUrl);
1208 }
1209 #endregion Google Sheets
1210 #region PuppeteerClient / based entirely on restclient
1212 {
1213 IAllowPuppeteerCommunicator WithAPIBase(string url);
1214 IAllowPuppeteerCommunicator WithUsePipes();
1215 }
1217 {
1218 IAllowPuppeteerEndpointDetails WithPuppeteerCommunicator(PuppeteerCommunicator communicator);
1219 }
1220 public interface IAllowPuppeteerEndpointDetails : IAllowPuppeteerExecution, IAllowPuppeteerParameters, IAllowToGPALObject<IPuppeteerClient>
1221 {
1222 IAllowPuppeteerParametersOrExecution WithEndpoint(string endpoint);
1223 IAllowPuppeteerParametersOrExecution WithEndpoint(ApiEndpoint endpoint);
1224 IAllowPuppeteerParametersOrExecution WithResultName(string name);
1225 IAllowPuppeteerEndpointDetails WithSaveFile(GPALFile file);
1226 IAllowPuppeteerEndpointDetails WithName(string name);
1227 }
1228
1230 {
1231 IAllowPuppeteerParametersOrExecution WithUrl(string url);
1232 IAllowPuppeteerParametersOrExecution WithUrlFromResult(int resultIndex);
1233 IAllowPuppeteerParametersOrExecution WithUrlFromResult(string name);
1234 IAllowPuppeteerParametersOrExecution WithTabId(int tabId);
1235 IAllowPuppeteerParametersOrExecution WithTabIdFromResult(int resultIndex);
1236 IAllowPuppeteerParametersOrExecution WithTabIdFromResult(string name);
1237 IAllowPuppeteerParametersOrExecution WithWindowId(int windowId);
1238 IAllowPuppeteerParametersOrExecution WithWindowIdFromResult(int resultIndex);
1239 IAllowPuppeteerParametersOrExecution WithWindowIdFromResult(string name);
1240 IAllowPuppeteerParametersOrExecution WithKey(string key);
1241 IAllowPuppeteerParametersOrExecution WithKeyFromResult(int resultIndex);
1242 IAllowPuppeteerParametersOrExecution WithKeyFromResult(string name);
1243 IAllowPuppeteerParametersOrExecution WithCss(string css);
1244 IAllowPuppeteerParametersOrExecution WithCssFromResult(int resultIndex);
1245 IAllowPuppeteerParametersOrExecution WithCssFromResult(string name);
1246 IAllowPuppeteerParametersOrExecution WithElements(List<GPALElement> gpalElement);
1247 IAllowPuppeteerParametersOrExecution WithElementFromResult(int resultIndex);
1248 IAllowPuppeteerParametersOrExecution WithElementFromResult(string name);
1249 IAllowPuppeteerParametersOrExecution WithXPath(string xpath);
1250 IAllowPuppeteerParametersOrExecution WithXPathFromResult(int resultIndex);
1251 IAllowPuppeteerParametersOrExecution WithXPathFromResult(string name);
1252 IAllowPuppeteerParametersOrExecution WithPixels(int pixels);
1253 IAllowPuppeteerParametersOrExecution WithPixelsFromResult(int resultIndex);
1254 IAllowPuppeteerParametersOrExecution WithPixelsFromResult(string name);
1255 IAllowPuppeteerParametersOrExecution WithReferrer(string referrer);
1256 IAllowPuppeteerParametersOrExecution WithReferrerFromResult(int resultIndex);
1257 IAllowPuppeteerParametersOrExecution WithReferrerFromResult(string name);
1258 IAllowPuppeteerExecution WithText(string text);
1259 IAllowPuppeteerExecution WithTextFromResult(int resultIndex);
1260 IAllowPuppeteerExecution WithTextFromResult(string name);
1263 IAllowPuppeteerParametersOrExecution WithElementId(string elementId);
1264 IAllowPuppeteerParametersOrExecution WithElementIdFromResult(int resultIndex);
1265 IAllowPuppeteerParametersOrExecution WithElementIdFromResult(string name);
1266 IAllowPuppeteerExecution SetValueFrom(string destSelector);
1267 IAllowPuppeteerParametersOrExecution WithHPixelsFromResult(int resultIndex);
1268 IAllowPuppeteerParametersOrExecution WithHPixelsFromResult(string name);
1269 IAllowPuppeteerParametersOrExecution WithVPixelsFromResult(int resultIndex);
1270 IAllowPuppeteerParametersOrExecution WithVPixelsFromResult(string name);
1271 IAllowPuppeteerParametersOrExecution WithModifiers(ModifierKeys modifierKeys);
1272 IAllowPuppeteerParametersOrExecution WithSessionToken(string sessionToken);
1273 IAllowPuppeteerExecution WithDeviceName(string deviceNameOrId);
1274 }
1276 {
1277 string Execute();
1278 T Execute<T>();
1281 Task<string> ExecuteAsync();
1282 Task<T> ExecuteAsync<T>();
1283 ResultCollection GetExecutionResults();
1284 IAllowPuppeteerExecution WithHeader(string name, string value);
1285 }
1286
1288 {
1289 IAllowPuppeteerParametersOrExecution WithParameters(params object[] parameters);
1290 IAllowPuppeteerParametersOrExecution WithParameters(object parameters);
1291 IAllowPuppeteerParametersOrExecution WithParametersFromResult(int resultIndex);
1292 IAllowPuppeteerParametersOrExecution WithParametersFromResult(string name);
1293 IAllowPuppeteerParametersOrExecution WithEncoding(Enums.ContentEncoding encoding);
1294 }
1295
1297 {
1298 IAllowPuppeteerWorkflow WithWorkflow(Action<RESTClient> workflow);
1299 [Workflow(Description = "Sets the timeout in milliseconds for While or Until loops.")]
1300 IAllowPuppeteerWorkflow WhileLoopTimeout(int timeoutMs);
1301
1302 [Workflow(Description = "Sets the maximum number of iterations for While or Until loops.")]
1303 IAllowPuppeteerWorkflow WhileLoopMaxIterations(int maxIterations);
1304 IAllowPuppeteerParametersOrExecution While(Func<bool> condition);
1305 IAllowPuppeteerParametersOrExecution Until(Func<bool> condition);
1306 }
1307
1309 {
1310 IAllowPuppeteerCheckNetworkIdleOrExecution WithTimeoutMs(int timeoutMs);
1311 IAllowPuppeteerCheckNetworkIdleOrExecution WithPruneMs(int pruneMs);
1312 IAllowPuppeteerCheckNetworkIdleOrExecution WithMaxConnections(int maxConnections);
1313 }
1314
1316 {
1317 IAllowPuppeteerScrollElement WithHPixels(int hPixels);
1318 IAllowPuppeteerScrollElement WithVPixels(int vPixels);
1319 }
1320
1322 {
1323 IAllowPuppeteerDragAndDrop WithDeltaX(int deltaX);
1324 IAllowPuppeteerDragAndDrop WithDeltaY(int deltaY);
1325 IAllowPuppeteerDragAndDrop WithOffsetX(int offsetX);
1326 IAllowPuppeteerDragAndDrop WithOffsetY(int offsetY);
1327 }
1328
1330 {
1331 IAllowPuppeteerAttribute WithAttribute(string attribute);
1332 IAllowPuppeteerAttribute WithValue(string value);
1333 }
1334
1336 {
1337 IAllowPuppeteerExecution WithSelectValue(string value);
1338 IAllowPuppeteerExecution WithSelectIndex(int index);
1339 }
1341 {
1342 IAllowPuppeteerExecution WithText(string text);
1343 }
1345 {
1346 IAllowPuppeteerStorageOptions WithStorageDomain(string domain);
1347 IAllowPuppeteerStorageOptions WithStoragePath(string path);
1348 IAllowPuppeteerStorageOptions WithStorageKey(string key);
1349 IAllowPuppeteerStorageOptions WithStorageStoreName(string storeName);
1350 IAllowPuppeteerStorageOptions WithStorageData(string data);
1351 IAllowPuppeteerStorageOptions WithDeleteAcrossOrigins(bool trueFalse);
1352 }
1353
1355 {
1356 IAllowPuppeteerExecution WithRangeValue(int rangeValue);
1357 }
1358
1359 public interface IAllowPuppeteerActions
1360 {
1362 IAllowPuppeteerExecution CaptureVisibleTab(ImageFormat imageFormat = ImageFormat.JPEG);
1363 IAllowPuppeteerExecution CastDesktop(string deviceNameOrId);
1364 IAllowPuppeteerExecution CastTab(string deviceNameOrId);
1365 IAllowPuppeteerExecution CloseTab(GPALUrl url = null);
1366 IAllowPuppeteerExecution CloseTab(int tabId);
1367 IAllowPuppeteerExecution CloseWindow(GPALUrl url = null);
1368 IAllowPuppeteerExecution CloseWindow(int tabId);
1369 IAllowPuppeteerStorageOptions DeleteStorage(WebsiteStorageType storageType);
1370 IAllowPuppeteerParameters ExecuteJavaScript(string script); // Removed params version as noted
1371 [Fluent(Description = "Issue an API request from inside the page, so it carries the session the browser already earned: its cookies, TLS fingerprint, header order and any anti-bot clearance. A relative url resolves against wherever the browser currently is")]
1372 IAllowPuppeteerParametersOrExecution Fetch(string url);
1373 IAllowPuppeteerParametersOrExecution WithVerb(string method);
1374 IAllowPuppeteerParametersOrExecution WithBody(string body);
1375 IAllowPuppeteerParametersOrExecution WithContentType(string contentType);
1376 IAllowPuppeteerParametersOrExecution WithHeaders(string[] headers);
1377 IAllowPuppeteerParametersOrExecution WithBytes(bool asBytes);
1384 IAllowPuppeteerInputText FillInAppend(dynamic elementOrelementId, int delayMs = 0);
1386 IAllowPuppeteerInputText FillInInsert(dynamic elementOrelementId, int delayMs = 0);
1388 IAllowPuppeteerInputText FillInOverwrite(dynamic elementOrelementId, int delayMs = 0);
1389 IAllowPuppeteerExecution Forward();
1390 IAllowPuppeteerExecution FullScreen();
1391 IAllowPuppeteerExecution GetReadyStatus(string sessionToken);
1392 IAllowPuppeteerParametersOrExecution CheckNetworkIdle(int maxConnections = 0);
1393 IAllowPuppeteerExecution GetShadowRoot(string css);
1394 IAllowPuppeteerExecution GetCurrentUrl();
1395 IAllowPuppeteerExecution GetCurrentWindow();
1396 IAllowPuppeteerStorageOptions GetStorage(WebsiteStorageType storageType);
1397 IAllowPuppeteerExecution GetLanguages();
1398 IAllowPuppeteerExecution GetUserAgent();
1400 IAllowPuppeteerExecution GoToTab(GPALUrl url);
1401 IAllowPuppeteerExecution GoToTab(int tabId);
1402 IAllowPuppeteerExecution GoToWindow(GPALUrl url);
1403 IAllowPuppeteerExecution GoToWindow(int tabId);
1404 IAllowPuppeteerExecution InElement(string elementId);
1405 IAllowPuppeteerExecution InjectScript(string script);
1406 IAllowPuppeteerExecution ClearInjectedScripts();
1407 IAllowPuppeteerExecution InMainDom();
1408 IAllowPuppeteerExecution InShadowDom(string elementId);
1409 IAllowPuppeteerExecution Maximize();
1410 IAllowPuppeteerExecution Minimize();
1411 IAllowPuppeteerExecution MoveTo(string elementId);
1412 IAllowPuppeteerExecution MoveTo(System.Drawing.Point point);
1413 IAllowPuppeteerExecution NewTab(GPALUrl url = null);
1414 IAllowPuppeteerExecution NextTab();
1415 IAllowPuppeteerExecution NextWindow();
1416 IAllowPuppeteerExecution Normal();
1417 IAllowPuppeteerExecution OpenWindow(GPALUrl url);
1418 IAllowPuppeteerExecution OverrideReferrer(string referrer);
1419 IAllowPuppeteerExecution PageDown(int pagesToScroll = 1);
1420 IAllowPuppeteerExecution PageEnd();
1421 IAllowPuppeteerExecution PageTop();
1422 IAllowPuppeteerExecution PageUp(int pagesToScroll = 1);
1423 IAllowPuppeteerExecution PressModifierKey(ModifierKeys modifierKeys);
1424 IAllowPuppeteerExecution PreviousTab();
1425 IAllowPuppeteerExecution PreviousWindow();
1426 IAllowPuppeteerExecution Refresh();
1427 IAllowPuppeteerExecution ReleaseModifierKey(ModifierKeys modifierKeys);
1428 IAllowPuppeteerExecution Restore();
1429 IAllowPuppeteerParametersOrExecution RightClickAndDownload(string elementId);
1430 IAllowPuppeteerParametersOrExecution LeftClickAndDownload(string elementId);
1431 IAllowPuppeteerParametersOrExecution LeftClickAndUpload(dynamic elementOrelementId);
1432 IAllowPuppeteerExecution ScrollWindowByHorizontal(int pixels);
1433 IAllowPuppeteerExecution ScrollWindowByVertical(int pixels);
1442 IAllowPuppeteerExecution SendString(string text, int delayMs = 0);
1443 IAllowPuppeteerExecution SendKey(byte vkcode);
1444 IAllowPuppeteerStorageOptions SetStorage(WebsiteStorageType storageType);
1445 IAllowPuppeteerExecution SetUserAgent(string userAgent);
1446 IAllowPuppeteerExecution StealthOverrideReferrer();
1447 IAllowPuppeteerExecution StopCasting();
1448 IAllowPuppeteerExecution SubmitForm(string elementId);
1449 IAllowPuppeteerExecution SwitchToDefaultContent();
1450 IAllowPuppeteerExecution SwitchToElement(string elementId);
1451 IAllowPuppeteerExecution SwitchToFrame(string elementId);
1452 IAllowPuppeteerExecution SwitchToShadowRoot(string elementId);
1453 IAllowPuppeteerExecution DownloadTo(string downloadPath);
1454 IAllowPuppeteerExecution FireChangeEvent(string elementId);
1455 IAllowPuppeteerExecution Focus(string elementId);
1456 IAllowPuppeteerExecution GetBoundingClientRect(string backendNodeId);
1457 IAllowPuppeteerExecution GetElementAttributeHash(string elementId);
1458 IAllowPuppeteerExecution GetPageSource();
1459 IAllowPuppeteerExecution GetParentNode(string elementId);
1460 IAllowPuppeteerExecution GetContentAndCss(string selectorPath);
1461 IAllowPuppeteerExecution GetCssAttributes(string elementId);
1462 IAllowPuppeteerExecution GetDomAttributes(string nodeId);
1463 IAllowPuppeteerExecution GetDomProperties(string backendNodeId);
1464 IAllowPuppeteerExecution HideElement(string elementId);
1465 IAllowPuppeteerExecution IsClickable(string elementId);
1466 IAllowPuppeteerExecution IsDisplayed(string elementId);
1467 IAllowPuppeteerExecution IsEnabled(string elementId);
1468 IAllowPuppeteerExecution IsEndOfPage();
1469 IAllowPuppeteerExecution IsVisibleInViewport(IGPALElement element);
1470 IAllowPuppeteerExecution IsVisibleInViewport(string elementId);
1471 IAllowPuppeteerParametersOrExecution LeftClick(dynamic elementOrelementId);
1472 IAllowPuppeteerParametersOrExecution LeftDoubleClick(dynamic elementOrelementId);
1473 IAllowPuppeteerParametersOrExecution MiddleClick(dynamic elementOrelementId);
1474 IAllowPuppeteerParametersOrExecution RightClick(dynamic elementOrelementId);
1475 IAllowPuppeteerSelectOptions SelectClick(string elementHandle); // objectid
1476 IAllowPuppeteerExecution ScrollIntoView(dynamic elementOrelementId);
1477 IAllowPuppeteerExecution WindowInnerHeight();
1478 IAllowPuppeteerExecution WindowInnerWidth();
1479 IAllowPuppeteerExecution WindowOuterHeight();
1480 IAllowPuppeteerExecution WindowOuterWidth();
1481 IAllowPuppeteerExecution WindowPageOffsetX();
1482 IAllowPuppeteerExecution WindowPageOffsetY();
1483 IAllowPuppeteerExecution WindowScreenLeft();
1484 IAllowPuppeteerExecution WindowScreenTop();
1485 IAllowPuppeteerExecution Hover(string elementId);
1486 IAllowPuppeteerExecution Evaluate(string xpath);
1487 IAllowPuppeteerExecution EvaluateAll(string xpath);
1488 IAllowPuppeteerExecution QuerySelector(string css);
1489 IAllowPuppeteerExecution QuerySelectors(string css);
1490 IAllowPuppeteerExecution ScrollWindow(int hPixels, int vPixels);
1491 IAllowPuppeteerExecution ClearReferrer();
1492 IAllowPuppeteerExecution TopBrowser();
1493
1494
1495 // Multi-parameter methods with fluent steps
1496 IAllowPuppeteerExecution ScrollElement(int hPixels, int vPixels);
1497 IAllowPuppeteerAttribute SetAttribute(string elementId);
1498 IAllowPuppeteerRangeValue SetRange(string elementId);
1499 IAllowPuppeteerScrollElement ScrollElement(string elementId);
1500 IAllowPuppeteerDragAndDrop DragAndDrop(string elementId);
1501 IAllowPuppeteerAttribute GetAttribute(string elementId); // Returns IAllowRESTAttribute, skips WithValue}
1502 }
1509 #endregion Puppeteer
1510 #region GPAL URL
1514 public interface IAllowGPALUrlForUrl : IAllowToGPALObject<IGPALUrl>
1515 {
1520 }
1521
1525 public interface IAllowGPALUrlStorageType : IAllowToGPALObject<IGPALUrl>
1526 {
1531 }
1532
1571
1582
1586 public interface IGPALUrl :
1591 {
1595 string Url { get; }
1596
1597 List<StorageAction> Add(StorageAction storageAction);
1598 List<StorageAction> Add(List<StorageAction> storageActions);
1599
1603 IReadOnlyList<StorageAction> GetActions();
1604 }
1605 #endregion GPAL URL
1606}
Browser object that contains the fluent methods to create your Browser workflow. Instatiated using G...
Definition Browser.cs:68
delegate CallIfStatus CallAfterFillInDelegate(IBrowser browser, IGPALGrid< string > tokens, int tokenIdx)
Delegate callback for the CallAfterFillIn EventHandler which will be invoked after each row of tokens...
delegate CallIfStatus CallOnFailDelegate(IBrowser browser, GPALFailure failure, string detail)
Delegate for the CallOnFail handler, invoked when something fails that the workflow,...
delegate CallIfStatus CallIfDelegate(IBrowser browser, List< IGPALElement > foundElements, List< IGPALElement > matchedElements, Selector selector, bool matchedAll)
Delegate callback for the CallIfFound/CallIfNotFound EventHandlers which will be invoked when a selec...
Represents a URL with optional pre-navigation storage cleanup / inspection actions....
Definition GPALUrl.cs:53
Represents a single storage-related action to perform before navigating to a URL.
Definition GPALUrl.cs:274
Class to define database usage. Currently only used for input from a table, sql or stored procedure....
Pseudo element used in Applications and Browser workflows for image matching and unified automation....
GPAL File object instantied with GPAL.File Used to load tokens into a GPALGrid [rows/columns].
Definition GPALFile.cs:36
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
Definition GPAL.cs:49
Describes an API request for .Fetch to issue from inside the page, so it carries the session the brow...
GPAL Selector used to locate Application and Browser elements. Instantiated with GPAL....
Definition Selector.cs:56
Allow Browser Settings, Goto, WaitOnDocumentReady.
What a workflow may say once .WithCallFilter has said which call it is after. Taking a template only ...
Starting interface - only allows setting the target URL.
IAllowGPALUrlStorageType ForUrl(string url)
Sets the target URL (blank or null becomes https://google.com).
Allow setting the storage data parameter for 'set' operations.
IAllowGPALUrlStorageItemConfig WithStorageData(string data)
Optional: domain override.
Interface after deleting a specific item - allows optional path/domain.
IAllowGPALUrlStorageItemConfig WithStorageKey(string key)
Specific key for the current storage type.
IAllowGPALUrlStorageItemConfig WithDeleteAcrossOrigins(bool trueFalse)
OttoMagic Only: For delete operations without a domain, limit to origin? true = delete across origins...
IAllowGPALUrlStorageItemConfig WithStorageDomain(string domain)
Optional: domain override.
IAllowGPALUrlStorageItemConfig WithStorageStoreName(string storeName)
For indexedDb, this is the 'table' the object store, they call it a store name.
IAllowGPALUrlStorageItemConfig WithStoragePath(string path)
Optional: path (e.g. cookie path, object store name).
IAllowGPALUrlStorageItemConfig WithUserDefined(string userDefined)
User defined data, strictly used for filtering in GPAL. Can store data of value.
Interface after URL is set - allows selecting storage type.
IAllowGPALUrlStorageItemConfig WithStorageType(WebsiteStorageType type)
Start declaring the storage action with storage type first.
IAllowAfterAnySelector InShadowDom(Selector shadowDomSelector)
NOTE: can only use CSS selectors in shadow dom.
IAllowPuppeteerInputText FillInInsert(dynamic elementOrelementId, int delayMs=0)
IAllowPuppeteerExecution SendString(string text, int delayMs=0)
Simulates typing: dispatches real key events character-by-character. Honors GPAL.TypingDelay when del...
IAllowPuppeteerInputText FillInOverwrite(dynamic elementOrelementId, int delayMs=0)
IAllowPuppeteerInputText FillInAppend(dynamic elementOrelementId, int delayMs=0)
Sets the element's value directly (fast path) - does NOT honor GPAL.TypingDelay. delayMs only paces ...
IAllowBrowserActionOrAnySelector SetAttribute(string value)
Directly sets a DOM attribute on the found element(s) via element.setAttribute(attribute,...
IAllowBrowserActionOrAnySelector SetValueFrom(Selector selector)
Copies the value from the element matched by selector into the element(s) matched by the preceding I...
IAllowSetAttributeValue WithAttribute(string attribute)
Names the DOM attribute to set on the found element(s). Must be followed by IAllowSetAttributeValue....
string RestApiBaseUrl
Where this browser's GPALRestAPI is listening, e.g. http://localhost:3117/, taken from the port it an...
Public interface exposed to consumers.
string Url
The target URL (never null).
IReadOnlyList< StorageAction > GetActions()
List of storage actions to perform before navigation.
One Win32 desktop object a browser is running on. Reached from the browser that is on it,...
Every hidden desktop this process has made, and the screen itself. Peek and Return move the screen,...