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 true
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,
111 // IAllowOCRSettingsOrExecute,
116 IAllowToGPALObject<IBrowser>
117 {
118 // Public properties
119 bool? FileDownloaded { [Data(Description = "True if the most recent download action successfully downloaded a file", Submenu = "Browser State")] get; set; }
120 BrowserType BrowserType { [Data(Description = "Return the current browser type", Submenu = "Browser State")] get; }
121 IWebDriver BrowserDriver { [Data(Description = "The browser driver controlling the current Browser", Submenu = "Browser State")] get; }
126 string RestApiBaseUrl { [Data(Description = "Where this browser's GPALRestAPI is listening, e.g. http://localhost:3117/, taken from the port it announced while starting", Submenu = "Browser State")] get; }
127 int CurrentTabIdx { [Data(Description = "Index of the currently active browser tab/window", Submenu = "Browser State")] get; }
128 string CurrentUrl { [Data(Description = "The URL of the page currently loaded in the browser", Submenu = "Browser State")] get; }
129 string BrowserVersion { [Data(Description = "The version of the browser being automated", Submenu = "Browser State")] get; }
130 object JavaScriptResultObj { [Data(Description = "The result object returned by the most recent ExecuteJavaScriptObj call", Submenu = "Browser State")] get; }
131 string JavaScriptResultStr { [Data(Description = "The result string returned by the most recent ExecuteJavaScriptStr call", Submenu = "Browser State")] get; }
132 PuppeteerCommunicator PuppeteerCommunicator { [Data(Description = "Communicator used to send/receive messages to the Puppeteer engine for this Browser", Submenu = "Engines")] get; }
133 IPuppeteerClient PuppeteerClient { [Data(Description = "The Puppeteer client used to issue commands when this Browser is using the Puppeteer engine", Submenu = "Engines")] get; }
134 int ServerResponseCode { [Data(Description = "HTTP status code of the most recent page navigation/response", Submenu = "Browser State")] get; set; } // CAVEAT: public set: unsure why visual studio will not let me use internal set in Broser without set here, like everywhere else
135 string SiteMapSource { [Data(Description = "The sitemap text the last GetSiteMapUrls read", Submenu = "Browser State")] get; }
136 IReadOnlyList<string> ColumnNames { [Data(Description = "The column names the last GetGrid read off the page itself, from the header row of a table it was pointed at", Submenu = "Grids")] get; }
137 bool UseOttoMagic { [Data(Description = "True if this Browser is using the OttoMagic automation engine", Submenu = "Browser State")] get; }
138 bool UsePuppeteer { [Data(Description = "True if this Browser is using the Puppeteer automation engine", Submenu = "Browser State")] get; }
139 bool UseSelenium { [Data(Description = "True if this Browser is using the Selenium automation engine", Submenu = "Browser State")] get; }
140 AutomationEngine AutomationEngine { [Data(Description = "The automation engine (OttoMagic, Puppeteer, or Selenium) used by this Browser", Submenu = "Browser State")] get; }
141 IRESTClient OttoMagicClient { [Data(Description = "The client for the OttoMagic REST API this browser is running", Submenu = "Engines")] get; }
142 [Settings(Description = "The hidden desktop this browser is running on, or null when it is on the visible one.")]
143 IHiddenDesktop HiddenDesktop { [Component(Description = "The hidden desktop this browser is running on, or null when it is on the desktop you are looking at")] get; }
144 [Scroll(Description = "Helper method to check whether the current page is at the bottom")]
145 bool IsEndOfPage();
146 bool IsAlive { [Data(Description = "Whether the browser is still running", Submenu = "Browser State")] get; }
147 // Public methods not covered by existing interfaces
148 [Action(Description = "Remove the CallIf handler everywhere it has been set. Use this once you are done using the handler.", Submenu = "Page")]
149 void RemoveCallIfHandlerEverywhere(CallIfDelegate func);
150 MagicHelper MagicHelper { [Data(Description = "The MagicHelper used to issue commands when this Browser is using the OttoMagic engine", Submenu = "Engines")] get; }
151 }
152
156 public interface IHiddenDesktop
157 {
158 [Settings(Description = "What this desktop is called. Browsers naming the same one share it.")]
159 string Name { [Data(Description = "What this desktop is called")] get; }
160 [Settings(Description = "How many visible top level windows are on it right now.")]
161 int WindowCount { [Data(Description = "Visible top level windows on it right now")] get; }
162 [Browser(Description = "Put this desktop on the screen for the default time, then put yours back.")]
163 string Peek();
164 [Browser(Description = "Put this desktop on the screen for this many milliseconds, then put yours back.")]
165 string Peek(int forMs);
166 [Browser(Description = "Give up GPAL's handle on this desktop. Closes nothing running there.")]
167 void Close();
168 [Browser(Description = "Close what is running on this desktop and then give up the handle on it.")]
169 void CloseEverything();
170 }
171
176 public interface IHiddenDesktops
177 {
178 [Settings(Description = "Every desktop made so far, in the order they were made.")]
179 IReadOnlyList<string> Names { [Data(Description = "Every desktop made so far, in the order they were made")] get; }
180 [Settings(Description = "One desktop by name, so a workflow that did not keep the browser can still reach it.")]
181 IHiddenDesktop this[string desktopName] { [Data(Description = "One hidden desktop, by name")] get; }
182 [Settings(Description = "Visible top level windows across every hidden desktop added up.")]
183 int WindowCount { [Data(Description = "Windows on every hidden desktop added up")] get; }
184 [Settings(Description = "True while the screen is on a hidden desktop and has not been handed back.")]
185 bool IsShowing { [Data(Description = "True while the screen is on a hidden desktop")] get; }
186 [Browser(Description = "Walk every hidden desktop that has windows, the default time each.")]
187 string Peek();
188 [Browser(Description = "Walk every hidden desktop that has windows, this many milliseconds each.")]
189 string Peek(int forMsEach);
190 [Browser(Description = "Put one named desktop on the screen for the default time.")]
191 string Peek(string desktopName);
192 [Browser(Description = "Put the screen back on the desktop a peek took it from. Safe from any thread.")]
193 bool Return();
194 [Browser(Description = "Give up GPAL's handles on every hidden desktop. Closes nothing running on them.")]
195 void CloseAll();
196 [Browser(Description = "Close what is running on every hidden desktop and then give up the handles.")]
197 void CloseEverything();
198 }
199
200 #region <BaseBrowserInterfaces>
201 public interface IAllowGoToOrGet : IAllowGoTo, IAllowGet, IAllowToGPALObject<IBrowser>
202 { }
204 { }
205 public interface IAllowBrowserType { [Settings(Description = "Set which browser type to run: Chrome (default), Edge or Firefox.", Submenu = "Engine")] IAllowBrowserSettingsOrGoTo WithBrowserType([BrowserType(Description = "Chrome, Edge or Firefox")] BrowserType browserType); }
206
208 {
209 [Settings(Description = "Set which engine to use to automate the browser: OttoMagic, Puppeteer (default) or Selenium.", Submenu = "Engine")]
210 IAllowBrowserSettingsOrGoTo WithAutomationEngine(AutomationEngine automationEngine);
211
212 }
213 public interface IAllowDebugPort
214 {
215 [Settings(Description = "Set debug port to use [57005 (0xdead) default]. Specify to reconnect to a browser session using .WithExistingCDPDebugPort. If both port and pipe are set, port is preferred.", Submenu = "Engine")]
216 IAllowBrowserSettingsOrGoTo WithCDPDebugPort(int debugPort = 0xdead);
217 [Settings(Description = "Use debug pipe for puppeteer commmunications. If both port and pipe are set, port is preferred.", Submenu = "Engine")]
218 IAllowBrowserSettingsOrGoTo WithCDPDebugPipe(bool trueFalse = false);
219 [Settings(Description = "Drive a browser whose GPALRestAPI is already running, here or on another machine, instead of launching one", Submenu = "Engine")]
220 IAllowBrowserSettingsOrGoTo WithGPALRestAPIUrl(string restApiUrl);
221 }
222 public interface IAllowExistingBrowser
223 {
224 [Settings(Description = "Drive a browser that is already running and listening on this remote debugging port, instead of starting one", Submenu = "Engine")]
225 IAllowBrowserActionOrAnySelector WithExistingCDPDebugPort(int debugPort = 6565);
226 }
228 {
229 [Settings(Description = "Load images in the page, this can affect layout and object coordinates, if that matters.", Submenu = "Stealth")]
230 IAllowBrowserSettingsOrGoTo WithLoadImages(bool trueFalse = true);
231 [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]", Submenu = "Selectors")]
232 IAllowBrowserSettingsOrGoTo WithScrollIntoView(bool trueFalse = true);
233 [Settings(Description = "Open PDF files externally, not in the browser. So, download the pdf.", Submenu = "Downloads")]
234 IAllowBrowserSettingsOrGoTo WithOpenPDFExternally(bool trueFalse = false);
235 [Settings(Description = "Prompt when downloading a file? [true default/false for headless]", Submenu = "Downloads")]
236 IAllowBrowserSettingsOrGoTo WithPromptForDownload(bool trueFalse = true);
237 [Settings(Description = "Location of the browser driver and where automatically updating the driver will occur. Default is executable directory.", Submenu = "Engine")]
238 IAllowBrowserSettingsOrGoTo WithDriverLocation([Directory(Description = "Location of browser driver for this instance. [./ (default)(same dir as exe)]")] string driverPath);
239 [Settings(Description = "Control whether popups are blocked", Submenu = "Stealth")]
240 IAllowBrowserSettingsOrGoTo WithBlockPopUps(bool trueFalse = true);
241 [Settings(Description = "Use javascript injection to interact with an element", Submenu = "Stealth")]
242 IAllowBrowserSettingsOrGoTo WithUseStealth(StealthType steathType);
243 [Settings(Description = "Always overwrite a file if it exists", Submenu = "Downloads")]
244 IAllowBrowserSettingsOrGoTo WithOverwriteExistingFile(bool trueFalse = true);
245 [Settings(Description = "Wait for browser page to finish loading", Submenu = "Waiting")]
246 IAllowBrowserSettingsOrGoTo WithWaitOnDocumentReady(int timeoutInMs);
247 [Settings(Description = "How long a click waits to see whether it started a navigation. [250 (default)] 0 skips the check", Submenu = "Waiting")]
248 IAllowBrowserSettingsOrGoTo WithNavigationGrace(int graceInMs);
249 [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.", Submenu = "Engine")]
250 IAllowBrowserSettingsOrGoTo WithHiddenDesktop(bool trueFalse = true);
251 [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.", Submenu = "Engine")]
252 IAllowBrowserSettingsOrGoTo WithHiddenDesktop(string desktopName);
253 [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.", Submenu = "Profile")]
254 IAllowBrowserSettingsOrGoTo WithProfileDataDirectory(string profilePath);
255 [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.", Submenu = "Profile")]
256 IAllowBrowserSettingsOrGoTo WithProfileUserName(string profileUserName);
257 [Settings(Description = "The name of the browser profile to use under the data-dir (sometime, might be same result as UserName)", Submenu = "Profile")]
258 IAllowBrowserSettingsOrGoTo WithProfileName(string profileName);
259 [Settings(Description = "Set the browser default download directory. Can be overriden with a fully qualified filename. [path/file/]", Submenu = "Downloads")]
260 IAllowBrowserSettingsOrGoTo WithDownloadLocation(string downloadPat);
261 [Settings(Description = "Use websockets to download for Right Click and Download", Submenu = "Downloads")]
262 IAllowBrowserSettingsOrGoTo WithUseDirectDownload(bool trueFalse = false);
263 [Settings(Description = "Set the time in seconds to wait for a download to finish before giving up.", Submenu = "Downloads")]
264 IAllowBrowserSettingsOrGoTo WithDownloadTimeoutInSec(int seconds = 60);
265 [Settings(Description = "Set the HTTP referrer to use when navigating every subsequent Get/Goto. Use empty string to clear.", Submenu = "Stealth")]
266 IAllowBrowserSettingsOrGoTo WithUseReferrer(string referrer = "");
267 [Settings(Description = "Set the user agent to use with any Goto or Get for the rest of the browser sessions", Submenu = "Stealth")]
268 IAllowBrowserSettingsOrGoTo WithUseUserAgent(string userAgent = "");
269 [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", Submenu = "Stealth")]
270 IAllowBrowserSettingsOrGoTo WithUserAgentFromBrowser(bool userAgentFromBrowser = true);
271 [Settings(Description = "Set whether or not to obey robots.txt (false - default).", Submenu = "Robots")]
272 IAllowBrowserSettingsOrGoTo WithObeyRobotsTxt(bool trueFalse = false);
273 [Settings(Description = "Set whether or not to respect robot meta tags noindex/nofollow/none (false - default).", Submenu = "Robots")]
274 IAllowBrowserSettingsOrGoTo WithRespectRobotMetaTags(bool trueFalse = false);
275 }
276 public interface IAllowNewTabOrWindow
277 {
278 [Action(Description = "Open url in a new tab", Submenu = "Tabs and Windows")]
279 IAllowBrowserActionOrAnySelector NewTab(GPALUrl url = null);
280 [Action(Description = "Open url in a new window", Submenu = "Tabs and Windows")]
281 IAllowBrowserActionOrAnySelector OpenWindow(GPALUrl url = null);
282 }
284 {
285 // return values
286 // 0 = not handled
287 // 1 = handled
288 // -1 = error
289 [Callback(Description = "GLOBAL based callback if any selector in any UOW is found")]
290 IAllowBrowserSettingsOrGoTo PersistentCallIfFound(Browser.CallIfDelegate CallIfFound);
291 [Callback(Description = "GLOBAL based callback if any selector in any UOW is NOT found")]
292 IAllowBrowserSettingsOrGoTo PersistentCallIfNotFound(Browser.CallIfDelegate CallIfNotFound);
293 [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")]
295 [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", Submenu = "Profile")]
296 IAllowBrowserSettingsOrGoTo WithCredentials(ICredentials credentials);
297 }
298 public interface IAllowCallBack
299 {
300 // return values
301 // 0 = not handled
302 // 1 = handled
303 // -1 = error
304 [Callback(Description = "UOW based callback if any selector in the UOW is found")]
305 IAllowAfterAnySelector CallIfFound(Browser.CallIfDelegate CallIfFound);
306 [Callback(Description = "UOW based callback if any selector in the UOW is NOT found")]
307 IAllowAfterAnySelector CallIfNotFound(Browser.CallIfDelegate CallIfNotFound);
308 [Callback(Description = "UOW based callback when a row of input is consumed and entered.\nUseful for chaining to another workflow")]
309 IAllowAfterAnySelector CallAfterFillIn(Browser.CallAfterFillInDelegate CallAfterFillIn);
310 }
311 public interface IAllowSizeControl : IAllowToGPALObject<IBrowser>
312 {
313 IAllowAllBrowserAndAllSelector Maximize { [Browser(Description = "Maximize the browser window", Submenu = "Windows")] get; }
314 IAllowAllBrowserAndAllSelector Minimize { [Browser(Description = "Minimize the browser window", Submenu = "Windows")] get; }
315 // IAllowAllBrowserAndAllSelector Normal { [Browser(Description = "Restore the browser window after fullscreen.")] get; }
316 IAllowAllBrowserAndAllSelector Restore { [Browser(Description = "Restore the browser window from maximize or full-screen.", Submenu = "Windows")] get; }
317 IAllowAllBrowserAndAllSelector FullScreen { [Browser(Description = "Put the browser in full-screen mode.", Submenu = "Windows")] get; }
318 [Browser(Description = "Set the desired browser window size.", Submenu = "Windows")]
319 IAllowAllBrowserAndAllSelector WithWindowSize(System.Drawing.Rectangle windowSize);
320 }
321 public interface IAllowHideElement
322 {
323 [Action(Description = "Hide the found element", Submenu = "Element")]
324 IAllowBrowserActionOrAnySelector Hide(Selector selector = null);
325 }
326 public interface IAllowSetAttributeValue
327 {
345 [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.", Submenu = "Element")]
347 }
349 {
358 [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.", Submenu = "Element")]
360 }
361 public interface IAllowWithAttribute
362 {
369 [Data(Description = "Names the attribute to set; must be followed by .SetAttribute(value) to specify the value and complete the action.", Submenu = "Grids")]
371 }
372 public interface IAllowClicks
373 {
374 [Action(Description = "Left click the found element.", Submenu = "Clicks")]
376 [Action(Description = "Left click the found element.", Submenu = "Clicks")]
377 IAllowBrowserActionOrAnySelector LeftClick(Selector selector);
378 [Action(Description = "M iddle click the found element.", Submenu = "Clicks")]
380 [Action(Description = "Left click the found select menu element.", Submenu = "Clicks")]
381 IAllowBrowserActionOrAnySelector SelectClick(SelectClickType selectClickType);
382 [Action(Description = "Stealth (Runtime.disable before) Left click the found element.", Submenu = "Clicks")]
383 IAllowBrowserActionOrAnySelector StealthLeftClick(Selector selector);
384 [Action(Description = "Left click the found element, pressing modifier key (none [default]) while clicking.", Submenu = "Clicks")]
385 IAllowBrowserActionOrAnySelector LeftClick(ModifierKeys modifierKeys);
386 [Action(Description = "Left click the found element, handling a download dialog after clicking.", Submenu = "Files")]
387 IAllowBrowserActionOrAnySelector LeftClickAndDownload(GPALFile filenames);
388 [Action(Description = "Left click the found element, handling an upload dialog after clicking.", Submenu = "Files")]
389 IAllowBrowserActionOrAnySelector LeftClickAndUpload(GPALFile filenames);
390 [Action(Description = "Left double click the found element, pressing modifier key (none [default]) while clicking.", Submenu = "Clicks")]
391 IAllowBrowserActionOrAnySelector LeftDoubleClick();
392 [Action(Description = "Right click the found element, pressing modifier key (none [default]) while clicking.", Submenu = "Clicks")]
393 IAllowBrowserActionOrAnySelector RightClick(Selector selector = null);
394
395 // returns the file name(s) saved to by adding to the ReturnedFilenames list
396 // if not overwriting files, then a timestamp is appended to the filename and returned
397 // if overwriting, the same filename is added to the list
398 // since we can iterate over multiple elements, this could right click and download multiple links, so filenames contains ALL expected filenames to save to
399 [Action(Description = "Save the element (if WithSelector is specified) or page to the GPALFile.", Submenu = "Files")]
400 IAllowBrowserActionOrAnySelector RightClickAndDownload(GPALFile filenames);
401 }
402 public interface IAllowWaitForWindow
403 {
404 [Wait(Description = "After an action is called (ie, LeftClick), wait for a window to open with this name (title)")]
405 IAllowAfterWaitForAndSizeControl WaitForWindow(string windowName);
406 [Wait(Description = "After an action is called (ie, LeftClick), wait for a window to open which name (title) matches the regular expression")]
407 IAllowAfterWaitForAndSizeControl WaitForWindowRegex(string windowNameRegex);
408 [Wait(Description = "The time in seconds to wait for a window to appear before giving up")]
409 IAllowAfterWaitForAndSizeControl WithWaitForWindowTimeout(int waitTimeInSeconds);
410
411 }
412 public interface IAllowFillInFrom
413 {
414 [Data(Description = "Send the specified string using the selector interaction type (selenium/javascript/hardware)", Submenu = "Keyboard")]
415 IAllowBrowserActionOrAnySelector SendString(string textToSend);
416 [Data(Description = "Send a control character specified by the VKCode (GPAL has some defined)", Submenu = "Keyboard")]
417 IAllowBrowserActionOrAnySelector SendKey(byte VKCode);
418 [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.", Submenu = "Keyboard")]
419 IAllowBrowserActionOrAnySelector PressModifierKey(ModifierKeys modifierKeys);
420 [Data(Description = "Release the modifier key specified (Control/Shift/Alt) as previously pressed.", Submenu = "Keyboard")]
421 IAllowBrowserActionOrAnySelector ReleaseModifierKey(ModifierKeys modifierKeys);
422
423 [Data(Description = "Fill in [overwrite] text from a string", Submenu = "Fill In")]
424 IAllowBrowserActionOrAnySelector FillInFrom(string textToUse);
425 [Data(Description = "Append to the end text from a string", Submenu = "Fill In")]
426 IAllowBrowserActionOrAnySelector AppendFrom(string textToUse);
427 [Data(Description = "Insert text (wherever the cursor is) from a string", Submenu = "Fill In")]
428 IAllowBrowserActionOrAnySelector InsertFrom(string textToUse);
429
430 [Data(Description = "Fill in [overwrite] text from a file. CSV values per line takenized for each input selector", Submenu = "Fill In")]
431 IAllowBrowserActionOrAnySelector FillInFrom(GPALFile inputFile);
432 [Data(Description = "Append to the end text from a file. CSV values per line takenized for each input selector", Submenu = "Fill In")]
433 IAllowBrowserActionOrAnySelector AppendFrom(GPALFile inputFile);
434 [Data(Description = "Insert text (wherever the cursor is) from a file. CSV values per line takenized for each input selector", Submenu = "Fill In")]
435 IAllowBrowserActionOrAnySelector InsertFrom(GPALFile inputFile);
436
437 [Data(Description = "Fill in [overwrite] text from a database query. Tokenized by each column per input per row", Submenu = "Fill In")]
438 IAllowBrowserActionOrAnySelector FillInFrom(GPALDatabase inpuDatabase);
439 [Data(Description = "Append to the end text from a database query. Tokenized by each column per input per row", Submenu = "Fill In")]
440 IAllowBrowserActionOrAnySelector AppendFrom(GPALDatabase inpuDatabase);
441 [Data(Description = "Insert text (wherever the cursor is) from a database query. Tokenized by each column per input per row", Submenu = "Fill In")]
442 IAllowBrowserActionOrAnySelector InsertFrom(GPALDatabase inpuDatabase);
443 [Data(Description = "Fill in [overwrite] text from a data grid. Tokenized List<List<string>> each string per input per list entry", Submenu = "Fill In")]
444 IAllowBrowserActionOrAnySelector FillInFrom(IGPALGrid<string> inputGrid);
445 [Data(Description = "Append to the end text from a data grid. Tokenized List<List<string>> each string per input per list entry", Submenu = "Fill In")]
446 IAllowBrowserActionOrAnySelector AppendFrom(IGPALGrid<string> inputGrid);
447 [Data(Description = "Insert text (wherever the cursor is) from a data grid. Tokenized List<List<string>> each string per input per list entry", Submenu = "Fill In")]
448 IAllowBrowserActionOrAnySelector InsertFrom(IGPALGrid<string> inputGrid);
449 [Data(Description = "Set the value of an input range element", Submenu = "Keyboard")]
450 IAllowBrowserActionOrAnySelector SetRange(int rangeValue);
451 };
452 public interface IAllowTabActions
453 {
454 [Browser(Description = "Close the current tab [no URL], or the tab with URL", Submenu = "Tabs")]
455 IAllowBrowserActionOrAnySelector CloseTab(dynamic URLorTabId = null);
456 IAllowBrowserActionOrAnySelector NextTab { [Browser(Description = "Move to the next tab (to the right)", Submenu = "Tabs")] get; }
457 IAllowBrowserActionOrAnySelector PreviousTab { [Browser(Description = "Move to the previous tab (to the left)", Submenu = "Tabs")] get; }
458 [Browser(Description = "Go to tab with URL", Submenu = "Tabs")]
459 IAllowBrowserActionOrAnySelector GoToTab(dynamic URLorTabTuple = null);
460 }
461 public interface IAllowInSelector
462 {
463 [Selector(Description = "Subsequent withselector searches are for elements nested under this element. Nesting is possible.")]
464 IAllowAfterAnySelector InElement(Selector selector);
465 [Selector(Description = "Subsequent withselector searches are for elements nested under this iframe. Nesting is possible.")]
466 IAllowAfterAnySelector InFrame(Selector selector);
467
473 [Selector(Description = "Subsequent selector are for elements in a shadowdom specified by the shadowdom selector. Nesting is possible.")]
475 [Selector(Description = "Reset back to the top level dom document for finding elements")]
476 IAllowAfterAnySelector InMainDom();
477 }
478 public interface IAllowScrolling
479 {
480 [Action(Description = "Scroll the specified web element n pixels horizontally", Submenu = "Element")]
481 IAllowBrowserActionOrAnySelector ScrollElementHorizontal(int scrollAmountInPixels);
482 [Action(Description = "Scroll the specified web element n pixels vertically", Submenu = "Element")]
483 IAllowBrowserActionOrAnySelector ScrollElementVertical(int scrollAmountInPixels);
484 }
485 public interface IAllowWindowScrollBy
486 {
487 [Browser(Description = "Scroll the browser window horizontally by scrollAmount pixels", Submenu = "Scrolling")]
488 IAllowBrowserActionOrAnySelector ScrollWindowHorizontal(int scrollAmount);
489 [Browser(Description = "Scroll the browser window veritcally by scrollAmount pixels", Submenu = "Scrolling")]
490 IAllowBrowserActionOrAnySelector ScrollWindowVertical(int scrollAmount);
491 }
492 public interface IAllowWindowActions
493 {
494 [Browser(Description = "Close the current window [no URL], or the window with URL", Submenu = "Windows")]
495 IAllowBrowserActionOrAnySelector CloseWindow(dynamic URLorId = null);
496 IAllowBrowserActionOrAnySelector NextWindow { [Browser(Description = "Move to the next window (to the right)", Submenu = "Windows")] get; }
497 IAllowBrowserActionOrAnySelector PreviousWindow { [Browser(Description = "Move to the previous window (to the left)", Submenu = "Windows")] get; }
498 [Browser(Description = "Go to window with URL", Submenu = "Windows")]
499 IAllowBrowserActionOrAnySelector GoToWindow(dynamic URLorId = null);
500 }
501 public interface IAllowPageControl
502 {
503 IAllowBrowserActionOrAnySelector Back { [Browser(Description = "Move back one entry in the browser history", Submenu = "Navigation")] get; }
504 IAllowBrowserActionOrAnySelector Forward { [Browser(Description = "Move forward one entry in the browser history", Submenu = "Navigation")] get; }
505 IAllowBrowserActionOrAnySelector PageDown { [Browser(Description = "Scroll one page down", Submenu = "Scrolling")] get; }
506 IAllowBrowserActionOrAnySelector PageEnd { [Browser(Description = "Scroll to page bottom", Submenu = "Scrolling")] get; }
507 IAllowBrowserActionOrAnySelector PageTop { [Browser(Description = "Scroll to page top", Submenu = "Scrolling")] get; }
508 IAllowBrowserActionOrAnySelector PageUp { [Browser(Description = "Scroll one page up", Submenu = "Scrolling")] get; }
509 IAllowBrowserActionOrAnySelector Refresh { [Browser(Description = "Refresh the current page", Submenu = "Navigation")] get; }
510 }
511 public interface IAllowExecuteJavaScript
512 {
513 [Browser(Description = "Execute the supplied javascript in the browser and return an integer in browser.JavaScriptResultObj", Submenu = "Scripts")]
514 IAllowBrowserActionOrAnySelector ExecuteJavaScriptObj(string javascript);
515 [Browser(Description = "Execute the supplied javascript in the browser and return an integer in browser.JavaScriptResultStr", Submenu = "Scripts")]
516 IAllowBrowserActionOrAnySelector ExecuteJavaScriptStr(string javascript);
517 }
518 public interface IAllowDialogHandling
519 {
520 [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.", Submenu = "Dialogs")]
521 IAllowBrowserActionOrAnySelector WithDialogsAccepted(bool accept);
522 [Browser(Description = "What a prompt hands back when dialogs are accepted. Not available on Selenium, where the driver answers the dialog itself.", Submenu = "Dialogs")]
523 IAllowBrowserActionOrAnySelector WithDialogText(string text);
524 [Browser(Description = "Stop answering dialogs, so they open and block again. Different from WithDialogsAccepted(false), which answers Cancel.", Submenu = "Dialogs")]
525 IAllowBrowserActionOrAnySelector ClearDialogHandling();
526 }
528 {
529 [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.", Submenu = "Windows")]
530 IAllowBrowserActionOrAnySelector GetWindowRectangle(out System.Drawing.Rectangle window);
531 }
532 public interface IAllowInjectScript
533 {
534 [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.", Submenu = "Scripts")]
535 IAllowBrowserActionOrAnySelector InjectScript(string script);
536 [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.", Submenu = "Scripts")]
537 IAllowBrowserActionOrAnySelector InjectScript(GPALFile scriptFile);
538 [Browser(Description = "Remove all scripts previously registered via InjectScript.", Submenu = "Scripts")]
539 IAllowBrowserActionOrAnySelector ClearInjectedScripts();
540 }
542 {
543 [Settings(Description = "Wait for browser network activity to idles. Defauilt is 0 connections.", Submenu = "Waiting")]
544 IAllowBrowserSettingsOrGoTo WithWaitOnIdleConnection(bool trueFalse = true);
545 [Settings(Description = "Timeout to wait for network idle = true. Defauilt is 500 ms.", Submenu = "Waiting")]
546 IAllowNetworkIdleSettings WithNetworkIdleTimeoutMs(int networkIdleTimeoutMs = 500);
547 [Settings(Description = "Timeout to wait for network idle = true. Defauilt is 500 ms.", Submenu = "Waiting")]
548 IAllowNetworkIdleSettings WithNetworkIdleMaxConnections(int maxConnections = 0);
549 [Settings(Description = "Duration to maintain network stats before pruning old data. Default is 10 seconds (10_000 ms).", Submenu = "Waiting")]
550 IAllowNetworkIdleSettings WithNetworkIdlePruneMs(int networkIdlePruneMs = 10_000);
551
552 }
553 #endregion <BaseInterfaces>
554
555 #region <Atoms>
556 public interface IAllowToGPALObject<TResult>
557 {
558 [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() ]")]
559 TResult ToGPALObject();
560 }
561 public interface IAllowWithPersistentSelector { [Settings(Description = "Add a selector that is looked for on every action, not just the one it is added to", Submenu = "Selectors")] IAllowBrowserSettingsOrGoTo WithPersistentSelector(Selector persistentSelector); }
562 public interface IAllowWithSelector : IAllowWithData { [Selector(Description = "Add a selector to this UOW")] IAllowAfterAnySelector WithSelector(Selector selector); }
563 public interface IAllowWithData
564 {
565 [Selector(Description = "Add literal data to a grid when using .GetGrid")] IAllowAfterAnySelector WithSelector(string literalData);
566 [Selector(Description = "Add literal data to a grid by invoking this function when using .GetGrid")] IAllowAfterAnySelector WithSelector(Func<string> dataFunction);
567 }
568 public interface IAllowSiteMapOperations
569 {
570 [Action("Get the current page source", Submenu = "Page")]
571 IAllowBrowserActionOrAnySelector GetPageSource(out string sitemapXML);
572 [Action("Carry on without the browser: hand back a RESTClient holding this browser's origin, cookies, user agent, accept language and credential", Submenu = "Calls")]
573 IAllowBrowserActionOrAnySelector ContinueAsRESTClient(out IRESTClient client);
574 [Action("Get the raw sitemap XML", Submenu = "Page")]
575 IAllowBrowserActionOrAnySelector GetSiteMap(out string sitemapXML);
576 [Action("Get the sitemap URLs as a List<string>")]
577 IAllowBrowserActionOrAnySelector GetSiteMapUrls(out List<string> sitemapXML, string sitemapUrl = null);
578 [Action("Save the sitemap URLs to a file, format chosen by the file extension", Submenu = "Page")]
579 IAllowBrowserActionOrAnySelector SaveSiteMapUrls(GPALFile sitemapUrlsFile);
580 [Action("Clear cached sitemap / LLM digest / hydration results, forcing the next Get/Save to refetch", Submenu = "Page")]
581 IAllowBrowserActionOrAnySelector ClearResultCache();
582 [Action("Get the current page source as an LLM digest")]
583 IAllowBrowserActionOrAnySelector GetLLMDigest(out LLMDigestResult digestResult, string ruleSetName = null);
584 [Action("Save to file, the current page source as an LLM digest")]
585 IAllowBrowserActionOrAnySelector SaveLLMDigest(GPALFile llmDigestFile, string ruleSetName = null);
586 [Action("Get the current page next.js hydrated data", Submenu = "Page")]
587 IAllowBrowserActionOrAnySelector GetHydratedData(out NextJsHydrationResult hydrationResult);
588 [Action("Save to file, the current page next.js hydrated data", Submenu = "Page")]
589 IAllowBrowserActionOrAnySelector SaveHydratedData(GPALFile hydrationFile);
590 }
591 public interface IAllowStorageAction
592 {
593 [Action("Run the get storage actions for storageType", Submenu = "Calls")]
594 IAllowStorageOutData RunGet(WebsiteStorageType storageType);
595 [Action("Run the set storage actions for storageType", Submenu = "Calls")]
596 IAllowBrowserActionOrAnySelector RunSet(WebsiteStorageType storageType);
597 [Action("Run the delete storage actions for storageType", Submenu = "Calls")]
598 IAllowBrowserActionOrAnySelector RunDelete(WebsiteStorageType storageType);
599 }
601 {
602 [Browser(Description = "The domain for the storage action", Submenu = "Storage")]
603 IAllowStorageOptions WithStorageDomain(string domain);
604 [Browser(Description = "The path for the storage action", Submenu = "Storage")]
605 IAllowStorageOptions WithStoragePath(string path);
606 [Browser(Description = "The key for the storage action", Submenu = "Storage")]
607 IAllowStorageOptions WithStorageKey(string key);
608 [Browser(Description = "The store name for the indexedDb action", Submenu = "Storage")]
609 IAllowStorageOptions WithStorageStoreName(string storeName);
610 [Browser(Description = "The user defined filter to help select wildcard storage actions", Submenu = "Storage")]
611 IAllowStorageOptions WithUserDefinedFilter(string userDefined);
612
613 }
614 public interface IAllowStorageData { [Browser(Description = "The data for storage set operations", Submenu = "Storage")] IAllowStorageOptions WithStorageData(string data); }
615 public interface IAllowStorageOutData { [Browser(Description = "The data for storage get operations", Submenu = "Storage")] IAllowBrowserActionOrAnySelector GetStorageData(out string data); }
616 public interface IAllowGoTo { [Browser(Description = "Go to the specified URL", Submenu = "Navigation")] IAllowBrowserActionOrAnySelector GoTo([URL()] GPALUrl URL); }
617 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", Submenu = "Navigation")] IAllowBrowserActionOrAnySelector Get([URL()] GPALUrl URL); }
618 public interface IAllowClose { [Browser(Description = "Close the current browser session. True [default] to kill web drivers running.", Submenu = "Navigation")] void Close(bool killWebDrivers = false); }
619 public interface IAllowFocus { [Action(Description = "Bring the current element (specified by .WithSelector) into focus.", Submenu = "Element")] IAllowBrowserActionOrAnySelector Focus(Selector selector = null); }
620 public interface IAllowHover { [Action(Description = "Hover the mouse over the current element (specified by .WithSelector). [hardware emulation (see .WithSimulateMouse)]", Submenu = "Mouse")] IAllowBrowserActionOrAnySelector Hover(Selector selector = null); }
621 public interface IAllowMoveTo { [Action(Description = "Move the cursor (focus) to the current element (specified by .WithSelector).", Submenu = "Mouse")] IAllowBrowserActionOrAnySelector MoveTo(Selector selector = null); }
622 public interface IAllowWithNextPageButton { [Data(Description = "When retrieving multiple pages of results, this is the button to click to get more results.", Submenu = "Pages")] IAllowWithPagesAndGridActions WithNextPageButton(Selector selector); }
623 public interface IAllowWithInfiniteScroll { IAllowWithPagesAndGridActions WithInfiniteScroll { [Data(Description = "When retrieving multiple pages of results, this imdocates scroll to page bottom to get more results.", Submenu = "Pages")] get; } }
624 public interface IAllowWithPages { [Data(Description = "Number of result pages to retrieve when retrieving multiple pages of results.", Submenu = "Pages")] IAllowGetGridAndFillInFrom WithPages(int numberOfPages); }
625 public interface IAllowWithTokensFrom
626 {
627 [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", Submenu = "Fill In")]
628 IAllowWithPagesAndFetch WithTokensFrom(IGPALGrid<string> inputGrid);
629 [Data(Description = "Values .Fetch drops into its request's numbered tokens, from a file. CSV values per line, one line per set of requests", Submenu = "Fill In")]
630 IAllowWithPagesAndFetch WithTokensFrom(GPALFile inputFile);
631 [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", Submenu = "Fill In")]
632 IAllowWithPagesAndFetch WithTokensFrom(GPALDatabase inputDatabase);
633 [Data(Description = "Values .Fetch drops into its request's numbered tokens, as a single row of comma separated values", Submenu = "Fill In")]
634 IAllowWithPagesAndFetch WithTokensFrom(string tokens);
635 }
636 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.", Submenu = "Grids")] IAllowWithHeaderOrFileActions GetGrid(ref IGPALGrid<string> returnGrid); }
637 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.", Submenu = "Grids")] IAllowBrowserActionOrAnySelector GetElements(out List<GPALElement> elements); }
638 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.", Submenu = "Grids")] IAllowWithHeaderOrFileActions WithHeader(string header); }
639 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.", Submenu = "Grids")] IAllowAfterAnySelectorExceptWithAll WithAllThatMatch(int rowCount = int.MaxValue); }
640 public interface IAllowWithHardware { IAllowAfterAnySelector WithHardware { [Settings(Description = "Use hardwre emulation to interact with this element", Submenu = "Engine")] get; } }
641 public interface IAllowWithJavaScript { IAllowAfterAnySelector WithJavaScript { [Settings(Description = "Use javascript injection to interact with this element", Submenu = "Engine")] get; } }
642 public interface IAllowWaitFor
643 {
644 [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)")]
645 IAllowAfterWaitFor WaitFor(WaitTime waitForTimeInMs);
646 [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)")]
647 IAllowAfterWaitFor WaitFor(Selector waitForSelector);
648 [Wait(Description = "Wait for the element(s) defined using .WithSelector to enter the specified state.")]
649 IAllowAfterWaitFor WaitFor(ElementState elementState);
650 }
651 public interface IAllowWithGridToSave { [Data(Description = "Data GPALGrid used to save results, could be created in another/sub-workflow", Submenu = "Grids")] IAllowWithHeaderOrFileActions WithGridToSave(IGPALGrid<string> filename); }
652 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(); }
653 public interface IAllowDragAndDrop
654 {
655 [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")]
656 IAllowBrowserActionOrAnySelector DragAndDrop(Selector selector = null);
657 [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")]
658 IAllowBrowserActionOrAnySelector DragAndDrop(ModifierKeys modifierKeys);
659 }
660 public interface IAllowPrintDomElement
661 {
662 [Fluent(Description = "Print each element named by .WithSelector to a PDF of its own, or the page when no selector is set. Each file comes from GPALFile.Next")]
663 IAllowBrowserActionOrAnySelector PrintToPDF(GPALFile gpalFile);
664 [Fluent(Description = "Print orientation for PrintToPDF - use before calling PrintToPDF")]
665 IAllowBrowserActionOrAnySelector WithPageOrientation(PageOrientation pageOrientation);
666 }
667 public interface IAllowCasting
668 {
669 [Fluent(Description = "Cast the current tab to the specified device")]
670 IAllowBrowserActionOrAnySelector CastTab(string deviceNameOrId);
671 [Fluent(Description = "Cast the desktop to the specified device")]
672 IAllowBrowserActionOrAnySelector CastDesktop(string deviceNameOrId);
673 [Fluent(Description = "Stop casting to device")]
675 }
676 #endregion <Atoms>
677
678 #region <DerivedInterfaces>
679 // An emergent rule of thumb...
680 // If the word "Or" appears more than once, invent an umbrella term.
681 // And then derive stuff... from the derived stuff.
682 // Because nobody wants to look at IAllowGoToOrGlobalWaitOnDocumentReadyOrClose.
683 // .WithTokensFrom and .WithPages both feed .Fetch, so either can come first
684 public interface IAllowWithPagesAndFetch
687 { }
696 public interface IAllowAnySelector
699 { }
704
712
716 public interface IAllowCallTemplate
718 {
719 [Action(Description = "Wait for the page to make a matching call and hand it back as a request ready to issue", Submenu = "Calls")]
720 IAllowBrowserActionOrAnySelector CaptureCallTemplate(out GPALRequest template);
721 }
722
750 public interface IAllowFetch
751 {
752 [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)")]
754 [Action(Description = "Record what the page asks for, so an endpoint can be read off a site", Submenu = "Calls")]
755 IAllowBrowserActionOrAnySelector CaptureCalls(bool capture = true);
756 [Action(Description = "Record what the page asks for and hand back everything recorded so far", Submenu = "Calls")]
757 IAllowBrowserActionOrAnySelector CaptureCalls(out List<GPALCall> calls);
758 [Action(Description = "Forget everything recorded so far, so what comes next is what happens next", Submenu = "Calls")]
759 IAllowBrowserActionOrAnySelector ClearCapturedCalls();
760 [Settings(Description = "Only record calls whose url holds this", Submenu = "Calls")]
761 IAllowCallTemplate WithCallFilter(string urlFragment);
762 }
810 // NOTE: Add to BELOW LIST what is added here
828 // NOTE: Add to this list what is added above
865 // , IAllowBrowserActionOrAnySelector
866 { }
867 #endregion <DerivedInterfaces>
868 #region Workflow Interfaces
869 public interface IAllowRun
870 {
871 [Workflow(Description = "Runs the workflows added to this browser, in the order they were added.")]
873 }
875 {
876 [Workflow(Description = "Executes the workflow while the predicate returns true.")]
877 IAllowBrowserActionOrAnySelector While(Func<Browser, bool> predicate);
878
879 [Workflow(Description = "Executes the workflow until the specified selector finds at least one element.")]
881
882 [Workflow(Description = "Executes the workflow until the predicate returns true.")]
883 IAllowBrowserActionOrAnySelector Until(Func<Browser, bool> predicate);
884
885 [Workflow(Description = "Sets the timeout in milliseconds for While or Until loops.")]
886 IAllowWorkflowExecution WhileLoopTimeout(int timeoutMs);
887
888 [Workflow(Description = "Sets the maximum number of iterations for While or Until loops.")]
889 IAllowWorkflowExecution WhileLoopMaxIterations(int maxIterations);
890 }
891 public interface IAllowScheduledWorkflow
892 {
893 [Workflow(Description = "Adds a workflow to be scheduled. It builds and owns whatever it drives.")]
894 IAllowScheduledWorkflowExecution WithWorkflow(Action workflow);
895 }
897 {
898 [Settings(Description = "How many workflows may be in flight at once. One, the default, runs them one after another.")]
899 IAllowScheduledWorkflowExecution WithMaxAtOnce(int howMany);
900 [Settings(Description = "The least time between two workflows starting. [250ms (default)] 0 starts them together.")]
901 IAllowScheduledWorkflowExecution WithStaggerStart(int delayInMs);
902 [Settings(Description = "How long to wait for them all before giving up and reporting the unfinished ones as failed. [no limit (default)]")]
903 IAllowScheduledWorkflowExecution WithTimeout(int timeoutInMs);
904 [Workflow(Description = "Runs every workflow added and waits for them all.")]
906 [Workflow(Description = "Runs every workflow added and hands back what happened to each.")]
907 IAllowScheduledWorkflowExecution Run(out List<WorkflowRun> runs);
908 }
909 public interface IAllowWorkflow
910 {
911 [Workflow(Description = "Defines a workflow to be executed repeatedly based on While or Until conditions.")]
912 IAllowWorkflowExecution WithWorkflow(Action<IBrowser> workflow);
913 }
914 #endregion Workflow Interfaces
915 #endregion <BrowserInterfaces>
916 #region <Element Assistant Interfaces>
921 public interface IAllowElementActions
922 {
923 [Action(Description = "Left click the specified element, pressing modifier key (none [default]) while clicking.")]
924 IAllowElementSettingsAndActions LeftClick(IGPALElement webElement);
925 [Action(Description = "Left click the specified element.")]
927 [Action(Description = "Left click the specified element, pressing modifier key (none [default]) while clicking.")]
928 IAllowElementSettingsAndActions LeftClick(ModifierKeys modifierKeys);
929 [Action(Description = "Left double click the specified element, pressing modifier key (none [default]) while clicking.")]
930 IAllowElementSettingsAndActions LeftDoubleClick(IGPALElement webElement);
931 [Action(Description = "M iddle click the found element.")]
933 [Action(Description = "Right click the specified element, pressing modifier key (none [default]) while clicking.")]
934 IAllowElementSettingsAndActions RightClick(IGPALElement webElement);
935 [Data(Description = "Fill in [overwrite] text from a string")]
936 IAllowElementSettingsAndActions FillInFrom(string textToUse);
937 [Data(Description = "Insert text (wherever the cursor is) from a string")]
938 IAllowElementSettingsAndActions InsertFrom(string textToUse);
939 [Data(Description = "Append to the end text from a string")]
940 IAllowElementSettingsAndActions AppendFrom(string textToUse);
941 [Data(Description = "Send a control character specified by the VKCode (GPAL has some defined)")]
942 IAllowElementSettingsAndActions SendKey(byte VKCode);
943 [Data(Description = "Send the specified string using the selector interaction type (selenium/javascript/hardware)")]
944 IAllowElementSettingsAndActions SendString(string textToSend);
945 [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.")]
946 IAllowElementSettingsAndActions PressModifierKey(ModifierKeys modifierKeys);
947 [Data(Description = "Release the modifier key specified (Control/Shift/Alt) as previously pressed.")]
948 IAllowElementSettingsAndActions ReleaseModifierKey(ModifierKeys modifierKeys);
949 [Action(Description = "Scroll the specified element n pixels horizontally")]
950 IAllowElementSettingsAndActions ScrollElementHorizontal(int scrollAmount);
951 [Action(Description = "Scroll the specified element n pixels vertically")]
952 IAllowElementSettingsAndActions ScrollElementVertical(int scrollAmount);
953 }
954 public interface IAllowElementSetting : IAllowToGPALObject<ElementAssistant>
955 {
956 [ElementAssitant(Description = "Declare the element to interact with using the ElementAssistant")]
958 IAllowElementSettingsAndActions WithJavaScript { [Settings(Description = "Use javascript injection to interact with this element")] get; }
959 IAllowElementSettingsAndActions WithHardware { [Settings(Description = "Use hardwre emulation to interact with this element")] get; }
960 }
961
962 #endregion <\Element Interfaces>
963 #region <File Interface>
964 public interface IAllowFileActions
965 {
966 // One save/append syntax. Output format and delimiter come from the GPALFile: its extension
967 // (.csv, .tsv/.txt, .xlsx, .json, .xml, .yaml, ...) or its explicit .WithDelimiter settings.
968 [File(Description = "Save the retrieved grid. Output format and delimiter are determined by the GPALFile (its extension, or explicit file settings).")]
970 [File(Description = "Append the retrieved grid. Output format and delimiter are determined by the GPALFile (its extension, or explicit file settings).")]
972 [File(Description = "Hand back what .Fetch retrieved, as a JSON array holding one response body per page requested.")]
973 IAllowBrowserActionOrAnySelector SaveTo(ref string data);
974 }
975 #endregion
976 #region Graphics Interface
977 public interface IAllowScreenshot
978 {
979 [GPAL(Description = "Capture a screenshot")]
980 IAllowGraphicSettings CaptureScreen(object ApplicationOrBrowser = null);
981
982 }
983 // NOTE: TODO: might these be used in Convertor class?
984 public interface IAllowGraphicSettings
985 {
986 [GPAL(Description = "Save to BASE64 string")]
987 IAllowGraphicSettings ToBase64String(out string base64String);
988 [Data(Description = "Returns the last captured screenshot as a Bitmap")]
989 IAllowGraphicSettings ToBitmap(out Bitmap base64String);
990 [File(Description = "Save to file (overwrite)")]
991 IAllowGraphicSettings SaveTo(GPALFile File);
992
993 }
994 public interface IImageHelper : IAllowGraphicSettings, IAllowScreenshot, IAllowToGPALObject<IImageHelper>
995 {
996
997 }
998 #endregion Graphics Interface
999 #region MagicHelper
1000 public interface IMagicHelper
1001 {
1002 // CalculateHash, GetFullUrl, GetRandomStarWarsQuery and LaunchBrowser are static on MagicHelper: they need no
1003 // browser, so they must not require one to exist. Reaching them through an instance did
1004 [Browser(Description = "Navigates browser history back", Submenu = "Navigation")]
1005 void Back();
1006 [Action(Description = "A screenshot of the visible part of the tab", Submenu = "Page")]
1007 string CaptureVisibleTab();
1008 string CheckNetworkIdle(int? maxConnections = null, int? timeoutMs = null, int? pruneMs = null);
1009 [Browser(Description = "Closes a tab by URL or tab ID", Submenu = "Tabs")]
1010 TabTuple CloseTab(dynamic URLorTabId = null);
1011 bool DeleteStorage(WebsiteStorageType storageType, bool deleteAcrossOrigins = false, string domain = null, string path = null, string key = null, string storeName = null);
1012 [Browser(Description = "Navigates browser history forward", Submenu = "Navigation")]
1013 void Forward();
1014 [Browser(Description = "Sets browser to full screen", Submenu = "Windows")]
1015 void FullScreen();
1016 [Browser(Description = "Navigates to a URL", Submenu = "Navigation")]
1017 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...
1018 [Data(Description = "Gets content and CSS for a elementId", Submenu = "Element")]
1019 string GetContentAndCss(string elementId);
1020 [Data(Description = "The computed styles of the element", Submenu = "Element")]
1021 Dictionary<string, object> GetCssAttributes(string elementId);
1022 [Data(Description = "The attributes of the element", Submenu = "Element")]
1023 Dictionary<string, object> GetDomAttributes(string elementId);
1024 [Data(Description = "The DOM properties of the element", Submenu = "Element")]
1025 Dictionary<string, object> GetDomProperties(string elementId);
1026 [Browser(Description = "Gets the current URL", Submenu = "Navigation")]
1027 string GetCurrentUrl();
1028 [Data(Description = "Gets the ready status NOTE: if no page is loaded, this will return null cause there is no content script", Submenu = "Page")]
1029 string GetReadyStatus();
1030 [Data(Description = "Gets the shadow root for an elementId", Submenu = "Find Elements")]
1031 GPALElement GetShadowRoot(string Css);
1032 string GetStorage(WebsiteStorageType storageType, string domain = null, string path = null, string key = null, string storeName = null);
1033 [Browser(Description = "Navigates to a URL", Submenu = "Navigation")]
1034 TabTuple GoTo(GPALUrl URL);
1035 [Action(Description = "Navigates to a tab by URL or tab ID", Submenu = "Tabs and Windows")]
1036 TabTuple GotoTab(dynamic URLorTabId);
1037 [Browser(Description = "Returns the browser window inner/outer height/widge { y: window.innerHeight, x: window.width, height: window.outerHeight, width: window.outerWidth }", Submenu = "Windows")]
1038 System.Drawing.Rectangle GetWindowRectangle();
1039 [Browser(Description = "Switches context to an element NOTE: InFrame and InElement are identical in implementation", Submenu = "Frames")]
1040 void SwitchToElement(string elementId); // in element and in iframe are the same thing
1041 [Settings(Description = "Switches context to iframe NOTE: InFrame and InElement are identical in implementation")]
1042 void InFrame(string elementId); // in element and in iframe are the same thing
1043 [Browser(Description = "Minimizes the browser window", Submenu = "Windows")]
1044 void Minimize();
1045 [Browser(Description = "Maximizes the browser window", Submenu = "Windows")]
1046 void Maximize();
1047 [Action(Description = "Scrolls an element into view by ID", Submenu = "Mouse")]
1048 void MoveTo(string elementiId);
1049 [Browser(Description = "Restores the browser window to normal", Submenu = "Windows")]
1050 void Normal();
1051 [Action(Description = "Opens a new tab with optional URL", Submenu = "Tabs and Windows")]
1052 TabTuple NewTab(GPALUrl URL = null);
1053 [Browser(Description = "Switches to the next tab", Submenu = "Tabs")]
1054 TabTuple NextTab();
1055 [Browser(Description = "How many tabs the browser actually has open, which is not the same as how many GPAL opened", Submenu = "Tabs")]
1056 int TabCount();
1057 [Action(Description = "Overrides the referrer URL", Submenu = "Referrer and User Agent")]
1058 void OverrideReferrer(string referrer);
1059 [Action(Description = "Overrides the browser's user agent string", Submenu = "Referrer and User Agent")]
1060 void SetUserAgent(string userAgent);
1061 [Scroll(Description = "Scrolls the page down")]
1062 void PageDown();
1063 [Scroll(Description = "Scrolls to the page end")]
1064 void PageEnd();
1065 [Scroll(Description = "Scrolls to the page top")]
1066 void PageTop();
1067 [Scroll(Description = "Scrolls the page up")]
1068 void PageUp();
1069 [Data(Description = "Press the specified modifier keys", Submenu = "Keyboard")]
1070 void PressModifierKey(ModifierKeys modifierKeys);
1071 [Browser(Description = "Switches to the previous tab", Submenu = "Tabs")]
1072 TabTuple PreviousTab();
1073 [Browser(Description = "Refreshes the current page", Submenu = "Navigation")]
1074 void Refresh();
1075 [Data(Description = "Press the specified modifier keys", Submenu = "Keyboard")]
1076 void ReleaseModifierKey(ModifierKeys modifierKeys);
1077 [Browser(Description = "Restores the browser window", Submenu = "Windows")]
1078 void Restore();
1079 [Browser(Description = "Scrolls the window horizontally by pixels", Submenu = "Scrolling")]
1080 void ScrollWindowHorizontal(int pixels);
1081 [Browser(Description = "Scrolls the window vertically by pixels", Submenu = "Scrolling")]
1082 void ScrollWindowVertical(int pixels);
1083 void SetRange(string elementId, int rangeValue);
1084 bool SetStorage(WebsiteStorageType storageType, string data, string domain = null, string path = null, string key = null, string storeName = null);
1085 [Action(Description = "Overrides referrer stealthily", Submenu = "Referrer and User Agent")]
1086 void SetGoogleReferrer();
1087 [Settings(Description = "Names the file the next download should land under")]
1088 void WithDownloadFile(string downloadPath);
1089 [Action(Description = "Focuses an element by ID", Submenu = "Mouse")]
1090 void Focus(string elementId);
1091 [Action(Description = "Fires a change event on an element by ID", Submenu = "Input")]
1092 void FireChangeEvent(string elementId);
1093 [Scroll(Description = "Scrolls an element into view by ID")]
1094 void ScrollIntoView(string elementId);
1095 void ScrollElement(string elementId, int hPixels, int vPixels);
1096 [Data(Description = "Gets the attribute hash of an element", Submenu = "Element")]
1097 string GetElementAttributeHash(string elementId);
1098 [Action(Description = "Get the html source of the current page", Submenu = "Page")]
1099 string GetPageSource();
1100 [Data(Description = "Gets the parent node of an element by ID", Submenu = "Find Elements")]
1101 GPALElement GetParentNode(string elementId);
1102 string GetAttribute(string elementId, string attribute);
1103 void SetAttribute(string elementId, string attribute, string value);
1104 void SetValueFromElement(string srcSelector, string destElementId);
1105 [Action(Description = "Performs a left click on an element by ID", Submenu = "Clicks")]
1106 void LeftClick(string elementId);
1107 [Action(Description = "Performs a left double click on an element by ID", Submenu = "Clicks")]
1108 void LeftDoubleClick(string elementId);
1109 [Action(Description = "Performs a left click on an element by ID", Submenu = "Clicks")]
1110 void MiddleClick(string elementId);
1111 [Action(Description = "Performs a right click on an element by ID", Submenu = "Clicks")]
1112 void RightClick(string elementId);
1113 void SelectClick(string elementId, dynamic indexOrValue);
1114 [Data(Description = "Checks if an element is visible in viewport by ID", Submenu = "Element")]
1115 bool IsVisibleInViewport(string elementId);
1116 [Scroll(Description = "Checks if the page is at the end")]
1117 bool IsEndOfPage();
1118 [Action(Description = "Hovers over an element by ID", Submenu = "Mouse")]
1119 void Hover(string elementId);
1120 void DragAndDrop(string elementId, int deltaX, int deltaY, int offsetX = 0, int offsetY = 0);
1121 [Data(Description = "Gets the window inner height", Submenu = "Window")]
1122 int WindowInnerHeight();
1123 [Data(Description = "Gets the window inner width", Submenu = "Window")]
1124 int WindowInnerWidth();
1125 [Data(Description = "Gets the window outer height", Submenu = "Window")]
1126 int WindowOuterHeight();
1127 [Data(Description = "Gets the window outer width", Submenu = "Window")]
1128 int WindowOuterWidth();
1129 string Fetch(string url, string method = null, string body = null, string contentType = null, string[] headers = null, bool asBytes = false);
1130 [Data(Description = "Gets the window page offset X", Submenu = "Window")]
1131 int WindowPageOffsetX();
1132 [Data(Description = "Gets the window page offset Y", Submenu = "Window")]
1133 int WindowPageOffsetY();
1134 [Data(Description = "Where the element is in the viewport, and its size", Submenu = "Element")]
1135 System.Drawing.Rectangle GetBoundingClientRect(string elementId);
1136 [Action(Description = "Hides an element by ID", Submenu = "Input")]
1137 void HideElement(string elementId);
1138 [Browser(Description = "Registers a script to run on every new document load", Submenu = "Scripts")]
1139 void InjectScript(string script);
1140 [Browser(Description = "Removes all scripts previously registered via InjectScript", Submenu = "Scripts")]
1141 void ClearInjectedScripts();
1142 [Data(Description = "Whether the element can be clicked", Submenu = "Element")]
1143 bool IsClickAble(string elementId);
1144 [Action(Description = "Clears the referrer header", Submenu = "Referrer and User Agent")]
1145 void ClearReferrer();
1146 [Data(Description = "Evaluates an XPath expression to locate a single element", Submenu = "Find Elements")]
1147 GPALElement Evaluate(string xpath);
1148 [Data(Description = "Evaluates an XPath expression to locate multiple elements", Submenu = "Find Elements")]
1149 List<GPALElement> EvaluateAll(string xpath);
1150 [Data(Description = "Evaluates an XPath expression to locate a single element", Submenu = "Find Elements")]
1151 GPALElement EvaluatePersistent(string xpath);
1152 [Data(Description = "Evaluates an XPath expression to locate multiple elements", Submenu = "Find Elements")]
1153 List<GPALElement> EvaluateAllPersistent(string xpath);
1154 [Data(Description = "Gets the browser's preferred languages, most preferred first", Submenu = "Page")]
1155 string GetLanguages();
1156 [Data(Description = "Gets the user agent", Submenu = "Page")]
1157 string GetUserAgent();
1158 [Data(Description = "Get select menu option items", Submenu = "Element")]
1159 List<GPALElement> GetOptions(string elementId);
1160 void FillInAppend(string elementId, string text);
1161 void FillInInsert(string elementId, string text);
1162 void FillInOverwrite(string elementId, string text);
1163 void LeftClickAndDownload(string elementId, string filenameAndPath);
1164 void LeftClickAndUpload(string elementId, string filenameAndPath);
1165 void LeftClickAndUpload(string elementId, GPALFile filenamesAndPaths);
1166 [Data(Description = "Queries a single element using a CSS selector", Submenu = "Find Elements")]
1167 GPALElement QueryPersistentSelector(string css);
1168 [Data(Description = "Queries multiple elements using a CSS selector", Submenu = "Find Elements")]
1169 List<GPALElement> QueryPersistentSelectors(string css);
1170 [Data(Description = "Queries a single element using a CSS selector", Submenu = "Find Elements")]
1171 GPALElement QuerySelector(string css);
1172 [Data(Description = "Queries multiple elements using a CSS selector", Submenu = "Find Elements")]
1173 List<GPALElement> QuerySelectors(string css);
1174 void ScrollWindow(int hPixels, int vPixels);
1175 [Data(Description = "Sends a single key", Submenu = "Keyboard")]
1176 void SendKey(byte vkcode);
1177 void SendString(string text, int delayMs = 0);
1178 [Browser(Description = "Switches to the default content", Submenu = "Frames")]
1179 void SwitchToDefaultContent();
1180 // void SwitchToFrame(string elementId); // there is no switch to frame, ottomagic runs in all frames
1181 [Browser(Description = "Switches to a shadow root by element ID", Submenu = "Frames")]
1182 void SwitchToShadowRoot(string elementId);
1183 [Data(Description = "Gets browser settings", Submenu = "Recorder")]
1184 string GetBrowserSettings();
1185 [Data(Description = "Gets GPAL settings", Submenu = "Recorder")]
1186 string GetGpalSettings();
1187 [Data(Description = "Gets general settings", Submenu = "Recorder")]
1188 string GetSettings();
1189 [Data(Description = "Gets the workflow", Submenu = "Recorder")]
1190 string GetWorkflow();
1191 // Process LaunchBrowser(BrowserSettings browserSettings, string URL = "https://google.com", List<string> additionalArguments = null);
1192 [Browser(Description = "Brings the browser window to the top", Submenu = "Windows")]
1193 bool TopBrowser(Process process);
1194 [Action(Description = "Open a new window on the url", Submenu = "Tabs and Windows")]
1195 public WindowTuple OpenWindow(GPALUrl url = null);
1196 [Browser(Description = "Switch to a window", Submenu = "Windows")]
1197 public WindowTuple GoToWindow(dynamic urlOrId);
1198 [Browser(Description = "Close a window", Submenu = "Windows")]
1199 public WindowTuple CloseWindow(dynamic urlOrId);
1200 [Browser(Description = "Move to the next window (to the right)", Submenu = "Windows")]
1201 public WindowTuple NextWindow();
1202 [Browser(Description = "Move to the previous window (to the left)", Submenu = "Windows")]
1203 public WindowTuple PreviousWindow();
1204 [Browser(Description = "The window the browser is on", Submenu = "Windows")]
1205 public WindowTuple GetCurrentWindow();
1206 [Data(Description = "Gets the window screen left position", Submenu = "Window")]
1207 int WindowScreenLeft();
1208 [Data(Description = "Gets the window screen top position", Submenu = "Window")]
1209 int WindowScreenTop();
1210 }
1211 #endregion MagicHelper
1212 #region Google Sheets
1213 public interface IAllowSpreadsheetSelection : IAllowToGPALObject<IGoogleSheets>
1214 {
1215 [Settings(Description = "The spreadsheet to work on, by name or id")]
1216 IAllowSheetSelection WithSpreadsheet(string spreadsheetIdOrTitle);
1217 }
1218
1219 public interface IAllowSheetSelection : IAllowDataOperations, IAllowSheetOperations, IAllowToGPALObject<IGoogleSheets>
1220 {
1221 [Settings(Description = "The sheet to work on, by name or id")]
1222 IAllowInDataOperations WithSheet(object sheetNameOrId);
1223 [Action(Description = "The names of the sheets in the spreadsheet")]
1224 IAllowSheetSelection ListSheets(out IEnumerable<(string name, int sheetId)> sheets);
1225 [Action(Description = "Rename the spreadsheet")]
1226 IAllowSheetSelection SetSpreadsheetTitle(string title);
1227 }
1228
1230 {
1231 [Action(Description = "Rename the sheet")]
1232 IAllowSheetSelection SetSheetName(string sheetName);
1233 [Settings(Description = "The range to read, such as A1:C10")]
1234 IAllowDataOperations WithReadRange(string range);
1235 [Settings(Description = "The rows to write")]
1236 IAllowDataOperations WithData(IGPALGrid<string> data);
1237 [Settings(Description = "What kind of formatting to apply")]
1238 IAllowFormatSettings WithFormatType(FormatType formatType);
1239 }
1240
1242 {
1243 [Action(Description = "Add the data to the end of what the cell holds")]
1244 IAllowDataOperations AppendToCell(string cell);
1245 [Action(Description = "Add the data to the start of what the cell holds")]
1246 IAllowDataOperations PrependToCell(string cell);
1247 [Settings(Description = "The range to write to, such as A1:C10")]
1248 IAllowSheetOperations WithWriteRange(string range);
1249 [Action(Description = "The sum of the range")]
1250 IAllowDataOperations CalculateSum(out string result);
1251 [Action(Description = "How many cells in the range hold a value")]
1252 IAllowDataOperations CalculateCount(out string result);
1253 }
1254
1256 {
1257 [Action(Description = "Delete the sheet")]
1258 IAllowSheetSelection DeleteSheet(object sheetNameOrId);
1259 [Action(Description = "Write the data to the sheet")]
1260 IAllowDataOperations WriteToSheet(object sheetNameOrId);
1261 }
1262
1263 public interface IAllowInsertSettings
1264 {
1265 [Settings(Description = "Where in the cell text to insert")]
1266 IAllowInsertSettings WithInsertPosition(int position);
1267 [Settings(Description = "Text to put between what is inserted and what was there")]
1268 IAllowInsertSettings WithInsertSeparator(string separator);
1269 [Action(Description = "Insert the data into the cell")]
1270 IAllowDataOperations InsertAtCell(string cell);
1271 }
1272
1273 public interface IAllowFormatSettings
1274 {
1275 [Settings(Description = "The value for the chosen format")]
1276 IAllowFormatRange WithFormatValue(object formatValue);
1277 [Settings(Description = "How the text is aligned")]
1278 IAllowFormatRange WithAlignmentFormatValue(HorizontalAlignmentType alignment);
1279 [Settings(Description = "How the text is aligned")]
1280 IAllowFormatRange WithAlignmentFormatValue(VerticalAlignmentType alignment);
1281 [Settings(Description = "How numbers are shown")]
1282 IAllowFormatRange WithNumberFormatValue(NumberFormatType numberFormat);
1283 [Settings(Description = "How far the text is turned")]
1284 IAllowFormatRange WithTextRotationFormatValue(TextRotationType rotation);
1285 [Settings(Description = "The color to apply")]
1286 IAllowFormatRange WithColorFormatValue(Color color);
1287 }
1288 public interface IAllowFormatRange
1289 {
1290 [Action(Description = "Apply the format to the range")]
1291 IAllowInDataOperations FormatRange(string range);
1292 }
1294 {
1295 [Settings(Description = "The Apps Script function the trigger runs")]
1296 IAllowTriggerSettings WithTriggerFunction(string functionName);
1297
1298 }
1299 public interface IAllowTriggerSettings : IAllowWithTriggerFunction, IAllowToGPALObject<IGoogleSheets>
1300 {
1301 [Settings(Description = "How often a time trigger runs")]
1302 IAllowTriggerSettings WithTriggerSchedule(TriggerScheduleType schedule);
1303 [Action(Description = "Create the trigger")]
1304 IAllowDataOperations CreateTrigger(GoogleTriggerType triggerType);
1305 }
1306 public interface IAllowScriptOperations : IAllowToGPALObject<IGoogleSheets>
1307 {
1308 [Settings(Description = "The Apps Script project to work on")]
1309 IAllowScriptOperations WithProjectId(string projectId);
1310 [Settings(Description = "The name of the script file in the project")]
1311 IAllowScriptOperations WithScriptName(string scriptName);
1312 [Settings(Description = "Who may call the web app")]
1313 IAllowScriptOperations WithScriptAccess(ScriptAccessType access);
1314 [Settings(Description = "Whose account the web app runs as")]
1315 IAllowScriptOperations WithExecuteAs(ExecuteAsType executeAs);
1316 [Settings(Description = "The description of the deployment")]
1317 IAllowScriptOperations WithDeploymentDescription(string description);
1319 //IAllowScriptOperations WithVersionNumber(int versionNumber);
1320 [Action(Description = "Upload the script to the project")]
1321 IAllowDeployWebApp UploadScript(string scriptContent);
1322 [Action(Description = "Upload the script to the project")]
1323 IAllowDeployWebApp UploadScript(GPALFile scriptFile);
1324 }
1326 {
1327 [Action(Description = "Deploy the uploaded script as a web app and hand back its url")]
1328 IAllowDataOperations DeployScriptAsWebApp(out string webAppUrl);
1329 }
1331 {
1332 [Action(Description = "Save what was read")]
1333 IAllowSheetSelection SaveTo(out IGPALGrid<string> gPalGrid);
1334 [Action(Description = "Save what was read")]
1335 IAllowSheetSelection SaveTo(GPALFile gPALFile);
1336 }
1339 {
1340 [Settings(Description = "The Google account to use Sheets as")]
1341 IAllowSpreadsheetSelection WithCredentials(ICredentials credentials);
1342 [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.")]
1343 IAllowSpreadsheetSelection WithWebAppUrl(string webAppUrl);
1344 }
1345 #endregion Google Sheets
1346 #region PuppeteerClient / based entirely on restclient
1348 {
1349 }
1351 {
1352 [Settings(Description = "Sets the PuppeteerCommunicator used to send commands to the puppeteer/CDP server", Submenu = "Request")]
1353 IAllowPuppeteerEndpointDetails WithPuppeteerCommunicator(PuppeteerCommunicator communicator);
1354 }
1355 public interface IAllowPuppeteerEndpointDetails : IAllowPuppeteerExecution, IAllowPuppeteerParameters, IAllowToGPALObject<IPuppeteerClient>
1356 {
1357 [Settings(Description = "Sets a custom endpoint path to call directly, bypassing the built-in ApiEndpoint enum", Submenu = "Request")]
1358 IAllowPuppeteerParametersOrExecution WithEndpoint(string endpoint);
1359 [Settings(Description = "Sets the endpoint to call, resolved from the given ApiEndpoint value", Submenu = "Request")]
1360 IAllowPuppeteerParametersOrExecution WithEndpoint(ApiEndpoint endpoint);
1361 [Settings(Description = "Sets the name under which this execution's result will be stored, for later retrieval via the WithXFromResult methods", Submenu = "Request")]
1362 IAllowPuppeteerParametersOrExecution WithResultName(string name);
1363 [Settings(Description = "Save the result to this file", Submenu = "Request")]
1364 IAllowPuppeteerEndpointDetails WithSaveFile(GPALFile file);
1365 [Settings(Description = "Sets the display name for this client", Submenu = "Request")]
1366 IAllowPuppeteerEndpointDetails WithName(string name);
1367 }
1368
1370 {
1371 [Settings(Description = "Sets the url parameter for the request", Submenu = "Navigation")]
1372 IAllowPuppeteerParametersOrExecution WithUrl(string url);
1373 [Data(Description = "Sets the url parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1374 IAllowPuppeteerParametersOrExecution WithUrlFromResult(int resultIndex);
1375 [Data(Description = "Sets the url parameter from the named result of a previous execution", Submenu = "From Result")]
1376 IAllowPuppeteerParametersOrExecution WithUrlFromResult(string name);
1377 [Settings(Description = "Sets the tab id parameter for the request", Submenu = "Navigation")]
1378 IAllowPuppeteerParametersOrExecution WithTabId(int tabId);
1379 [Data(Description = "Sets the tab id parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1380 IAllowPuppeteerParametersOrExecution WithTabIdFromResult(int resultIndex);
1381 [Data(Description = "Sets the tab id parameter from the named result of a previous execution", Submenu = "From Result")]
1382 IAllowPuppeteerParametersOrExecution WithTabIdFromResult(string name);
1383 [Settings(Description = "Sets the window id parameter for the request", Submenu = "Navigation")]
1384 IAllowPuppeteerParametersOrExecution WithWindowId(int windowId);
1385 [Data(Description = "Sets the window id parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1386 IAllowPuppeteerParametersOrExecution WithWindowIdFromResult(int resultIndex);
1387 [Data(Description = "Sets the window id parameter from the named result of a previous execution", Submenu = "From Result")]
1388 IAllowPuppeteerParametersOrExecution WithWindowIdFromResult(string name);
1389 [Settings(Description = "Sets the key parameter for the request", Submenu = "Storage")]
1390 IAllowPuppeteerParametersOrExecution WithKey(string key);
1391 [Data(Description = "Sets the key parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1392 IAllowPuppeteerParametersOrExecution WithKeyFromResult(int resultIndex);
1393 [Data(Description = "Sets the key parameter from the named result of a previous execution", Submenu = "From Result")]
1394 IAllowPuppeteerParametersOrExecution WithKeyFromResult(string name);
1395 [Settings(Description = "Sets the css selector parameter for the request", Submenu = "Element")]
1396 IAllowPuppeteerParametersOrExecution WithCss(string css);
1397 [Data(Description = "Sets the css selector parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1398 IAllowPuppeteerParametersOrExecution WithCssFromResult(int resultIndex);
1399 [Data(Description = "Sets the css selector parameter from the named result of a previous execution", Submenu = "From Result")]
1400 IAllowPuppeteerParametersOrExecution WithCssFromResult(string name);
1401 [Settings(Description = "Sets the gpalElements parameter, identifying the elements the request should act on", Submenu = "Element")]
1402 IAllowPuppeteerParametersOrExecution WithElements(List<GPALElement> gpalElement);
1403 [Data(Description = "Sets the elementId parameter from the result at the given index of a previous execution, then calls WithElementId", Submenu = "From Result")]
1404 IAllowPuppeteerParametersOrExecution WithElementFromResult(int resultIndex);
1405 [Data(Description = "Sets the elementId parameter from the named result of a previous execution, then calls WithElementId", Submenu = "From Result")]
1406 IAllowPuppeteerParametersOrExecution WithElementFromResult(string name);
1407 [Settings(Description = "Sets the xpath parameter for the request", Submenu = "Element")]
1408 IAllowPuppeteerParametersOrExecution WithXPath(string xpath);
1409 [Data(Description = "Sets the xpath parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1410 IAllowPuppeteerParametersOrExecution WithXPathFromResult(int resultIndex);
1411 [Data(Description = "Sets the xpath parameter from the named result of a previous execution", Submenu = "From Result")]
1412 IAllowPuppeteerParametersOrExecution WithXPathFromResult(string name);
1413 [Settings(Description = "Sets the pixels parameter for the request", Submenu = "Drag and Scroll")]
1414 IAllowPuppeteerParametersOrExecution WithPixels(int pixels);
1415 [Data(Description = "Sets the pixels parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1416 IAllowPuppeteerParametersOrExecution WithPixelsFromResult(int resultIndex);
1417 [Data(Description = "Sets the pixels parameter from the named result of a previous execution", Submenu = "From Result")]
1418 IAllowPuppeteerParametersOrExecution WithPixelsFromResult(string name);
1419 [Settings(Description = "Sets the referrer parameter for the request", Submenu = "Navigation")]
1420 IAllowPuppeteerParametersOrExecution WithReferrer(string referrer);
1421 [Data(Description = "Sets the referrer parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1422 IAllowPuppeteerParametersOrExecution WithReferrerFromResult(int resultIndex);
1423 [Data(Description = "Sets the referrer parameter from the named result of a previous execution", Submenu = "From Result")]
1424 IAllowPuppeteerParametersOrExecution WithReferrerFromResult(string name);
1425 [Settings(Description = "Sets the text parameter for the request", Submenu = "Element")]
1426 IAllowPuppeteerExecution WithText(string text);
1427 [Data(Description = "Sets the text parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1428 IAllowPuppeteerExecution WithTextFromResult(int resultIndex);
1429 [Data(Description = "Sets the text parameter from the named result of a previous execution", Submenu = "From Result")]
1430 IAllowPuppeteerExecution WithTextFromResult(string name);
1431 [Action(Description = "Where a file the browser downloads should end up")]
1433 [Action(Description = "Sets the upload path parameter(s) so a subsequent action uploads the given file(s)")]
1435 [Settings(Description = "Sets the elementId parameter for the request, resolving CSS selectors to an element handle if needed", Submenu = "Element")]
1436 IAllowPuppeteerParametersOrExecution WithElementId(string elementId);
1437 [Data(Description = "Sets the elementId parameter from the result at the given index of a previous execution, then calls WithElementId", Submenu = "From Result")]
1438 IAllowPuppeteerParametersOrExecution WithElementIdFromResult(int resultIndex);
1439 [Data(Description = "Sets the elementId parameter from the named result of a previous execution, then calls WithElementId", Submenu = "From Result")]
1440 IAllowPuppeteerParametersOrExecution WithElementIdFromResult(string name);
1441 [Action(Description = "Sets the value of the destination element identified by destSelector from the source element identified by the preceding WithCss or WithElementId call")]
1442 IAllowPuppeteerExecution SetValueFrom(string destSelector);
1443 [Data(Description = "Sets the horizontal pixels parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1444 IAllowPuppeteerParametersOrExecution WithHPixelsFromResult(int resultIndex);
1445 [Data(Description = "Sets the horizontal pixels parameter from the named result of a previous execution", Submenu = "From Result")]
1446 IAllowPuppeteerParametersOrExecution WithHPixelsFromResult(string name);
1447 [Data(Description = "Sets the vertical pixels parameter from the result at the given index of a previous execution", Submenu = "From Result")]
1448 IAllowPuppeteerParametersOrExecution WithVPixelsFromResult(int resultIndex);
1449 [Data(Description = "Sets the vertical pixels parameter from the named result of a previous execution", Submenu = "From Result")]
1450 IAllowPuppeteerParametersOrExecution WithVPixelsFromResult(string name);
1451 [Settings(Description = "Sets the modifier keys parameter for the request", Submenu = "Element")]
1452 IAllowPuppeteerParametersOrExecution WithModifiers(ModifierKeys modifierKeys);
1453 [Settings(Description = "Sets the session token parameter for the request", Submenu = "Request")]
1454 IAllowPuppeteerParametersOrExecution WithSessionToken(string sessionToken);
1455 [Settings(Description = "Sets the CSS parameter", Submenu = "Request")]
1456 IAllowPuppeteerExecution WithDeviceName(string deviceNameOrId);
1457 }
1459 {
1460 [Fluent(Description = "Synchronously executes the configured request and returns the result as a string")]
1461 string Execute();
1462 [Fluent(Description = "Synchronously executes the configured request and returns the result as a string")]
1463 T Execute<T>();
1464 // the chain is spent once it executes, so what comes back is the whole client rather than a slice of it,
1465 // the same as RESTClient.AndThen. Narrowing here meant the next call could not name its result
1466 [Fluent(Description = "Executes the configured request, then returns this client so further fluent calls can configure the next request")]
1467 IPuppeteerClient AndThen();
1468 [Fluent(Description = "Executes the configured request, then returns this client so further fluent calls can configure the next request")]
1469 IPuppeteerClient AndThen<T>();
1470 [Action(Description = "Asynchronously executes the configured request and returns the result as a string")]
1471 Task<string> ExecuteAsync();
1472 [Action(Description = "Asynchronously executes the configured request and returns the result as a string")]
1473 Task<T> ExecuteAsync<T>();
1474 [Data(Description = "Everything stored under a name so far, in the order it was stored")]
1475 ResultCollection GetExecutionResults();
1476 [Data(Description = "Every result stored under name, in the order it was stored, so a loop that ran five times answers with five")]
1477 IReadOnlyList<object> GetExecutionResults(string name);
1478 [Action(Description = "Empties what WithResultName has stored, so GetExecutionResults answers about what has happened since rather than everything since the client was made")]
1479 IAllowPuppeteerExecution ClearResults();
1480 IAllowPuppeteerExecution WithHeader(string name, string value);
1481 }
1482
1484 {
1485 [Settings(Description = "Sets the request parameters as an ordinal array", Submenu = "Request")]
1486 IAllowPuppeteerParametersOrExecution WithParameters(params object[] parameters);
1487 [Settings(Description = "Sets the request parameters from an object with named fields", Submenu = "Request")]
1488 IAllowPuppeteerParametersOrExecution WithParameters(object parameters);
1489 [Data(Description = "Sets the request parameters from the result at the given index of a previous execution", Submenu = "From Result")]
1490 IAllowPuppeteerParametersOrExecution WithParametersFromResult(int resultIndex);
1491 [Data(Description = "Sets the request parameters from the named result of a previous execution", Submenu = "From Result")]
1492 IAllowPuppeteerParametersOrExecution WithParametersFromResult(string name);
1493 [Settings(Description = "Sets the content encoding used for requests sent to the puppeteer communicator", Submenu = "Request")]
1494 IAllowPuppeteerParametersOrExecution WithEncoding(Enums.ContentEncoding encoding);
1495 }
1496
1498 {
1499 [Workflow(Description = "Adds a workflow step that invokes the given action against this client")]
1500 IAllowPuppeteerWorkflow WithWorkflow(Action<PuppeteerClient> workflow);
1501 [Workflow(Description = "Empties the declared workflow steps so the next loop runs a new set.")]
1502 IAllowPuppeteerWorkflow ClearWorkflows();
1503 [Workflow(Description = "Sets the timeout in milliseconds for While or Until loops.")]
1504 IAllowPuppeteerWorkflow WhileLoopTimeout(int timeoutMs);
1505
1506 [Workflow(Description = "Sets the maximum number of iterations for While or Until loops.")]
1507 IAllowPuppeteerWorkflow WhileLoopMaxIterations(int maxIterations);
1508 [Workflow(Description = "Repeat the workflow while the condition holds")]
1509 IAllowPuppeteerParametersOrExecution While(Func<bool> condition);
1510 [Workflow(Description = "Configures execution to repeat until the given condition returns true, subject to WhileLoopTimeout/WhileLoopMaxIterations")]
1511 IAllowPuppeteerParametersOrExecution Until(Func<bool> condition);
1512 }
1513
1515 {
1516 [Settings(Description = "Sets the timeout, in milliseconds, used by CheckNetworkIdle", Submenu = "Network Idle")]
1517 IAllowPuppeteerCheckNetworkIdleOrExecution WithTimeoutMs(int timeoutMs);
1518 [Settings(Description = "Sets the prune interval, in milliseconds, used by CheckNetworkIdle", Submenu = "Network Idle")]
1519 IAllowPuppeteerCheckNetworkIdleOrExecution WithPruneMs(int pruneMs);
1520 [Settings(Description = "Sets the maximum number of in-flight connections allowed before the network is considered busy, used by CheckNetworkIdle", Submenu = "Network Idle")]
1521 IAllowPuppeteerCheckNetworkIdleOrExecution WithMaxConnections(int maxConnections);
1522 }
1523
1525 {
1526 [Settings(Description = "Sets the horizontal pixels parameter for the request", Submenu = "Drag and Scroll")]
1527 IAllowPuppeteerScrollElement WithHPixels(int hPixels);
1528 [Settings(Description = "Sets the vertical pixels parameter for the request", Submenu = "Drag and Scroll")]
1529 IAllowPuppeteerScrollElement WithVPixels(int vPixels);
1530 }
1531
1533 {
1534 [Settings(Description = "Sets the horizontal drag delta parameter for a drag and drop", Submenu = "Drag and Scroll")]
1535 IAllowPuppeteerDragAndDrop WithDeltaX(int deltaX);
1536 [Settings(Description = "Sets the vertical drag delta parameter for a drag and drop", Submenu = "Drag and Scroll")]
1537 IAllowPuppeteerDragAndDrop WithDeltaY(int deltaY);
1538 [Settings(Description = "Sets the horizontal grab offset within the element for a drag and drop", Submenu = "Drag and Scroll")]
1539 IAllowPuppeteerDragAndDrop WithOffsetX(int offsetX);
1540 [Settings(Description = "Sets the vertical grab offset within the element for a drag and drop", Submenu = "Drag and Scroll")]
1541 IAllowPuppeteerDragAndDrop WithOffsetY(int offsetY);
1542 }
1543
1545 {
1546 [Data(Description = "Sets the attribute name parameter for SetAttribute/GetAttribute requests")]
1547 IAllowPuppeteerAttribute WithAttribute(string attribute);
1548 [Settings(Description = "Sets the attribute value parameter for SetAttribute requests", Submenu = "Element")]
1549 IAllowPuppeteerAttribute WithValue(string value);
1550 }
1551
1553 {
1554 [Settings(Description = "Set the value to choose from the Select menu", Submenu = "Element")]
1555 IAllowPuppeteerExecution WithSelectValue(string value);
1556 [Settings(Description = "Sets the index of the option to choose from a Select menu", Submenu = "Element")]
1557 IAllowPuppeteerExecution WithSelectIndex(int index);
1558 }
1560 {
1561 [Settings(Description = "Sets the text parameter for the request")]
1562 IAllowPuppeteerExecution WithText(string text);
1563 }
1565 {
1566 [Browser(Description = "Sets the storage domain parameter for storage operations")]
1567 IAllowPuppeteerStorageOptions WithStorageDomain(string domain);
1568 [Browser(Description = "Sets the storage path parameter for storage operations")]
1569 IAllowPuppeteerStorageOptions WithStoragePath(string path);
1570 [Browser(Description = "Sets the storage key parameter for storage operations")]
1571 IAllowPuppeteerStorageOptions WithStorageKey(string key);
1572 [Browser(Description = "Sets the storage store name parameter for IndexedDB storage operations")]
1573 IAllowPuppeteerStorageOptions WithStorageStoreName(string storeName);
1574 [Browser(Description = "Sets the storage data parameter for storage operations")]
1575 IAllowPuppeteerStorageOptions WithStorageData(string data);
1576 [Settings(Description = "Sets whether storage should be deleted across all origins, not just the current one", Submenu = "Storage")]
1577 IAllowPuppeteerStorageOptions WithDeleteAcrossOrigins(bool trueFalse);
1578 }
1579
1581 {
1582 [Settings(Description = "Sets the range value parameter for a SetRange request", Submenu = "Element")]
1583 IAllowPuppeteerExecution WithRangeValue(int rangeValue);
1584 }
1585
1586 public interface IAllowPuppeteerActions
1587 {
1588 [Browser(Description = "Configure this client to navigate the browser back one page in history", Submenu = "Navigation")]
1590 [Action(Description = "Configure this client to capture a screenshot of the visible tab in the given image format", Submenu = "Page")]
1591 IAllowPuppeteerExecution CaptureVisibleTab(ImageFormat imageFormat = ImageFormat.JPEG);
1592 [Fluent(Description = "Cast the desktop to the specified device name")]
1593 IAllowPuppeteerExecution CastDesktop(string deviceNameOrId);
1594 [Fluent(Description = "Cast the current tab to the specified device name")]
1595 IAllowPuppeteerExecution CastTab(string deviceNameOrId);
1596 [Browser(Description = "Configure this client to close the tab with the given URL, or the current tab if none is given", Submenu = "Tabs")]
1597 IAllowPuppeteerExecution CloseTab(GPALUrl url = null);
1598 [Browser(Description = "Configure this client to close the tab with the given tab id", Submenu = "Tabs")]
1599 IAllowPuppeteerExecution CloseTab(int tabId);
1600 [Browser(Description = "Configure this client to close the window containing the given URL, or the current window if none is given", Submenu = "Windows")]
1601 IAllowPuppeteerExecution CloseWindow(GPALUrl url = null);
1602 [Browser(Description = "Configure this client to close the window containing the tab with the given tab id", Submenu = "Windows")]
1603 IAllowPuppeteerExecution CloseWindow(int tabId);
1604 [Action(Description = "Configure this client to delete the given type of website storage", Submenu = "Storage")]
1605 IAllowPuppeteerStorageOptions DeleteStorage(WebsiteStorageType storageType);
1606 [Action(Description = "Configure this client to execute the given JavaScript in the page", Submenu = "Page")]
1607 IAllowPuppeteerParameters ExecuteJavaScript(string script); // Removed params version as noted
1608 [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")]
1609 IAllowPuppeteerParametersOrExecution Fetch(string url);
1610 [Settings(Description = "HTTP method for the request", Submenu = "Request")]
1611 IAllowPuppeteerParametersOrExecution WithVerb(string method);
1612 [Settings(Description = "Body to send with the request", Submenu = "Request")]
1613 IAllowPuppeteerParametersOrExecution WithBody(string body);
1614 [Settings(Description = "Content type of the body", Submenu = "Request")]
1615 IAllowPuppeteerParametersOrExecution WithContentType(string contentType);
1616 [Settings(Description = "Extra request headers, flattened to name, value, name, value", Submenu = "Request")]
1617 IAllowPuppeteerParametersOrExecution WithHeaders(string[] headers);
1618 [Settings(Description = "True to bring the response body back base64 encoded, which is what a file needs", Submenu = "Request")]
1619 IAllowPuppeteerParametersOrExecution WithBytes(bool asBytes);
1626 IAllowPuppeteerInputText FillInAppend(dynamic elementOrelementId, int delayMs = 0);
1628 IAllowPuppeteerInputText FillInInsert(dynamic elementOrelementId, int delayMs = 0);
1630 IAllowPuppeteerInputText FillInOverwrite(dynamic elementOrelementId, int delayMs = 0);
1631 [Browser(Description = "Configure this client to navigate the browser forward one page in history", Submenu = "Navigation")]
1632 IAllowPuppeteerExecution Forward();
1633 [Browser(Description = "Configure this client to make the browser window fullscreen", Submenu = "Windows")]
1634 IAllowPuppeteerExecution FullScreen();
1635 [Data(Description = "Configure this client to query the puppeteer server's ready status, optionally for a specific session token", Submenu = "Page")]
1636 IAllowPuppeteerExecution GetReadyStatus();
1637 [Action(Description = "Configure this client to check whether network activity has gone idle", Submenu = "Page")]
1638 IAllowPuppeteerParametersOrExecution CheckNetworkIdle(int maxConnections = 0);
1639 [Data(Description = "Configure this client to retrieve the shadow root of the element matching the given CSS selector", Submenu = "Find Elements")]
1640 IAllowPuppeteerExecution GetShadowRoot(string css);
1641 [Browser(Description = "Configure this client to retrieve the current page URL", Submenu = "Navigation")]
1642 IAllowPuppeteerExecution GetCurrentUrl();
1643 [Browser(Description = "Configure this client to retrieve information about the current browser window", Submenu = "Windows")]
1644 IAllowPuppeteerExecution GetCurrentWindow();
1645 [Data(Description = "Configure this client to retrieve the given type of website storage", Submenu = "Page")]
1646 IAllowPuppeteerStorageOptions GetStorage(WebsiteStorageType storageType);
1647 [Data(Description = "Configure this client to retrieve the browser's preferred languages, most preferred first", Submenu = "Page")]
1648 IAllowPuppeteerExecution GetLanguages();
1649 [Data(Description = "Configure this client to retrieve the browser's user agent string", Submenu = "Page")]
1650 IAllowPuppeteerExecution GetUserAgent();
1651 [Browser(Description = "Configure this client to navigate the current tab to the given URL, resolving relative URLs and checking robots.txt restrictions", Submenu = "Navigation")]
1653 [Browser(Description = "Configure this client to switch to the tab whose URL matches the given URL", Submenu = "Tabs")]
1654 IAllowPuppeteerExecution GoToTab(GPALUrl url);
1655 [Browser(Description = "Configure this client to switch to the tab with the given tab id", Submenu = "Tabs")]
1656 IAllowPuppeteerExecution GoToTab(int tabId);
1657 [Browser(Description = "Configure this client to switch to the window containing the tab whose URL matches the given URL", Submenu = "Windows")]
1658 IAllowPuppeteerExecution GoToWindow(GPALUrl url);
1659 [Browser(Description = "Configure this client to switch to the window containing the tab with the given tab id", Submenu = "Windows")]
1660 IAllowPuppeteerExecution GoToWindow(int tabId);
1661 [Settings(Description = "Configure this client to switch context into the element matching the given selector", Submenu = "Element")]
1662 IAllowPuppeteerExecution InElement(string elementId);
1663 [Browser(Description = "Configure this client to inject the given JavaScript into the page", Submenu = "Scripts")]
1664 IAllowPuppeteerExecution InjectScript(string script);
1665 [Browser(Description = "Configure this client to remove all previously injected scripts (via InjectScript)", Submenu = "Scripts")]
1666 IAllowPuppeteerExecution ClearInjectedScripts();
1667 [Browser(Description = "Configure this client to switch context back to the main document", Submenu = "Frames")]
1668 IAllowPuppeteerExecution InMainDom();
1669 [Settings(Description = "Configure this client to switch context into the shadow root of the element matching the given selector", Submenu = "Element")]
1670 IAllowPuppeteerExecution InShadowDom(string elementId);
1671 [Browser(Description = "Configure this client to maximize the browser window", Submenu = "Windows")]
1672 IAllowPuppeteerExecution Maximize();
1673 [Browser(Description = "Configure this client to minimize the browser window", Submenu = "Windows")]
1674 IAllowPuppeteerExecution Minimize();
1675 [Action(Description = "Configure this client to move the mouse to the element matching the given selector", Submenu = "Mouse")]
1676 IAllowPuppeteerExecution MoveTo(string elementId);
1677 [Action(Description = "Configure this client to move the mouse to a viewport coordinate instead of to an element, for targets with no DOM handle such as an image match", Submenu = "Mouse")]
1678 IAllowPuppeteerExecution MoveTo(System.Drawing.Point point);
1679 [Action(Description = "Configure this client to open a new tab navigated to the given URL, resolving relative URLs and checking robots.txt restrictions", Submenu = "Tabs and Windows")]
1680 IAllowPuppeteerExecution NewTab(GPALUrl url = null);
1681 [Browser(Description = "Configure this client to switch to the next tab", Submenu = "Tabs")]
1682 IAllowPuppeteerExecution NextTab();
1683 [Browser(Description = "Configure this client to switch to the next browser window", Submenu = "Windows")]
1684 IAllowPuppeteerExecution NextWindow();
1685 [Browser(Description = "Configure this client to restore the browser window to its normal (non-maximized, non-minimized) state", Submenu = "Windows")]
1686 IAllowPuppeteerExecution Normal();
1687 [Action(Description = "Configure this client to open a new browser window navigated to the given URL, resolving relative URLs and checking robots.txt restrictions", Submenu = "Tabs and Windows")]
1688 IAllowPuppeteerExecution OpenWindow(GPALUrl url);
1689 [Action(Description = "Configure this client to override the HTTP referrer sent with subsequent requests", Submenu = "Referrer and User Agent")]
1690 IAllowPuppeteerExecution OverrideReferrer(string referrer);
1691 [Scroll(Description = "Configure this client to scroll the page down by the given number of page heights")]
1692 IAllowPuppeteerExecution PageDown(int pagesToScroll = 1);
1693 [Scroll(Description = "Configure this client to scroll to the bottom of the page")]
1694 IAllowPuppeteerExecution PageEnd();
1695 [Scroll(Description = "Configure this client to scroll to the top of the page")]
1696 IAllowPuppeteerExecution PageTop();
1697 [Scroll(Description = "Configure this client to scroll the page up by the given number of page heights")]
1698 IAllowPuppeteerExecution PageUp(int pagesToScroll = 1);
1699 [Data(Description = "Configure this client to press and hold the given modifier key(s)", Submenu = "Keyboard")]
1700 IAllowPuppeteerExecution PressModifierKey(ModifierKeys modifierKeys);
1701 [Browser(Description = "Configure this client to switch to the previous tab", Submenu = "Tabs")]
1702 IAllowPuppeteerExecution PreviousTab();
1703 [Browser(Description = "Configure this client to switch to the previous browser window", Submenu = "Windows")]
1704 IAllowPuppeteerExecution PreviousWindow();
1705 [Browser(Description = "Configure this client to refresh the current page", Submenu = "Navigation")]
1706 IAllowPuppeteerExecution Refresh();
1707 [Data(Description = "Configure this client to release the given modifier key(s)", Submenu = "Keyboard")]
1708 IAllowPuppeteerExecution ReleaseModifierKey(ModifierKeys modifierKeys);
1709 [Browser(Description = "Configure this client to restore the browser window to its normal size", Submenu = "Windows")]
1710 IAllowPuppeteerExecution Restore();
1711 [Action(Description = "Configure this client to left-click the given element and download the resulting target", Submenu = "Files")]
1712 IAllowPuppeteerParametersOrExecution LeftClickAndDownload(string elementId);
1713 [Action(Description = "Configure this client to left-click the given element to open a file picker, then upload the file(s) set via UploadFrom", Submenu = "Files")]
1714 IAllowPuppeteerParametersOrExecution LeftClickAndUpload(dynamic elementOrelementId);
1715 [Scroll(Description = "Configure this client to scroll the browser window horizontally by the given number of pixels")]
1716 IAllowPuppeteerExecution ScrollWindowByHorizontal(int pixels);
1717 [Scroll(Description = "Configure this client to scroll the browser window vertically by the given number of pixels")]
1718 IAllowPuppeteerExecution ScrollWindowByVertical(int pixels);
1727 IAllowPuppeteerExecution SendString(string text, int delayMs = 0);
1728 [Data(Description = "Configure this client to send a key press for the given virtual key code, translating it to the corresponding DOM key and code", Submenu = "Keyboard")]
1729 IAllowPuppeteerExecution SendKey(byte vkcode);
1730 [Action(Description = "Configure this client to write the given type of website storage; combine with WithStorageDomain/WithStorageKey/WithStorageData etc to specify what to write", Submenu = "Storage")]
1731 IAllowPuppeteerStorageOptions SetStorage(WebsiteStorageType storageType);
1732 [Action(Description = "Configure this client to override the browser's user agent string for subsequent requests", Submenu = "Referrer and User Agent")]
1733 IAllowPuppeteerExecution SetUserAgent(string userAgent);
1734 [Action(Description = "Configure this client to override the HTTP referrer with https://www.google.com, to mimic arriving from a search engine", Submenu = "Referrer and User Agent")]
1735 IAllowPuppeteerExecution SetGoogleReferrer();
1736 [Fluent(Description = "Configure this client to stop any active screen casting")]
1737 IAllowPuppeteerExecution StopCasting();
1738 [Browser(Description = "Configure this client to switch context back to the main document", Submenu = "Frames")]
1739 IAllowPuppeteerExecution SwitchToDefaultContent();
1740 [Browser(Description = "Configure this client to switch context into the element matching the given selector", Submenu = "Frames")]
1741 IAllowPuppeteerExecution SwitchToElement(string elementId);
1742 [Browser(Description = "Configure this client to switch context into the iframe matching the given selector", Submenu = "Frames")]
1743 IAllowPuppeteerExecution SwitchToFrame(string elementId);
1744 [Browser(Description = "Configure this client to switch context into the shadow root of the element matching the given selector", Submenu = "Frames")]
1745 IAllowPuppeteerExecution SwitchToShadowRoot(string elementId);
1746 [Action(Description = "Where files the browser downloads should end up", Submenu = "Files")]
1747 IAllowPuppeteerExecution DownloadTo(string downloadPath);
1748 [Action(Description = "Configure this client to fire a DOM change event on the given element", Submenu = "Input")]
1749 IAllowPuppeteerExecution FireChangeEvent(string elementId);
1750 [Action(Description = "Configure this client to set keyboard focus on the given element", Submenu = "Mouse")]
1751 IAllowPuppeteerExecution Focus(string elementId);
1752 [Data(Description = "Configure this client to retrieve the bounding client rectangle of the given element", Submenu = "Element")]
1753 IAllowPuppeteerExecution GetBoundingClientRect(string backendNodeId);
1754 [Data(Description = "Configure this client to compute a hash of the given element's attributes, useful for detecting element changes", Submenu = "Element")]
1755 IAllowPuppeteerExecution GetElementAttributeHash(string elementId);
1756 [Action(Description = "Configure this client to retrieve the current page's HTML source", Submenu = "Page")]
1757 IAllowPuppeteerExecution GetPageSource();
1758 [Data(Description = "Configure this client to retrieve the parent node of the given element", Submenu = "Find Elements")]
1759 IAllowPuppeteerExecution GetParentNode(string elementId);
1760 [Data(Description = "Configure this client to retrieve the text content and computed CSS of the given element", Submenu = "Element")]
1761 IAllowPuppeteerExecution GetContentAndCss(string selectorPath);
1762 [Data(Description = "Configure this client to retrieve the CSS attributes of the given element", Submenu = "Element")]
1763 IAllowPuppeteerExecution GetCssAttributes(string elementId);
1764 [Data(Description = "Configure this client to retrieve the DOM attributes of the given element", Submenu = "Element")]
1765 IAllowPuppeteerExecution GetDomAttributes(string nodeId);
1766 [Data(Description = "Configure this client to retrieve the DOM properties of the given element", Submenu = "Element")]
1767 IAllowPuppeteerExecution GetDomProperties(string backendNodeId);
1768 [Action(Description = "Configure this client to hide the given element", Submenu = "Input")]
1769 IAllowPuppeteerExecution HideElement(string elementId);
1770 [Data(Description = "Configure this client to check whether the given element is clickable", Submenu = "Element")]
1771 IAllowPuppeteerExecution IsClickable(string elementId);
1772 [Data(Description = "Configure this client to check whether the given element is displayed", Submenu = "Element")]
1773 IAllowPuppeteerExecution IsDisplayed(string elementId);
1774 [Data(Description = "Configure this client to check whether the given element is enabled", Submenu = "Element")]
1775 IAllowPuppeteerExecution IsEnabled(string elementId);
1776 [Scroll(Description = "Configure this client to check whether the page is scrolled to its end")]
1777 IAllowPuppeteerExecution IsEndOfPage();
1778 [Data(Description = "Configure this client to check whether the given element is visible in the viewport", Submenu = "Element")]
1779 IAllowPuppeteerExecution IsVisibleInViewport(IGPALElement element);
1780 [Data(Description = "Configure this client to check whether the element with the given backend node id is visible in the viewport", Submenu = "Element")]
1781 IAllowPuppeteerExecution IsVisibleInViewport(string elementId);
1782 [Action(Description = "Configure this client to left-click the given element", Submenu = "Clicks")]
1783 IAllowPuppeteerParametersOrExecution LeftClick(dynamic elementOrelementId);
1784 [Action(Description = "Configure this client to double left-click the given element", Submenu = "Clicks")]
1785 IAllowPuppeteerParametersOrExecution LeftDoubleClick(dynamic elementOrelementId);
1786 [Action(Description = "Configure this client to middle-click the given element", Submenu = "Clicks")]
1787 IAllowPuppeteerParametersOrExecution MiddleClick(dynamic elementOrelementId);
1788 [Action(Description = "Configure this client to right-click the given element", Submenu = "Clicks")]
1789 IAllowPuppeteerParametersOrExecution RightClick(dynamic elementOrelementId);
1790 [Action(Description = "Open a drop-down's options by clicking the element; follow with WithSelectValue or WithSelectIndex", Submenu = "Clicks")]
1791 IAllowPuppeteerSelectOptions SelectClick(string elementHandle); // objectid
1792 [Scroll(Description = "Configure this client to scroll the given element into view")]
1793 IAllowPuppeteerExecution ScrollIntoView(dynamic elementOrelementId);
1794 [Data(Description = "Configure this client to retrieve the browser window's inner height", Submenu = "Window")]
1795 IAllowPuppeteerExecution WindowInnerHeight();
1796 [Data(Description = "Configure this client to retrieve the browser window's inner width", Submenu = "Window")]
1797 IAllowPuppeteerExecution WindowInnerWidth();
1798 [Data(Description = "Configure this client to retrieve the browser window's outer height", Submenu = "Window")]
1799 IAllowPuppeteerExecution WindowOuterHeight();
1800 [Data(Description = "Configure this client to retrieve the browser window's outer width", Submenu = "Window")]
1801 IAllowPuppeteerExecution WindowOuterWidth();
1802 [Data(Description = "Configure this client to retrieve the page's horizontal scroll offset", Submenu = "Window")]
1803 IAllowPuppeteerExecution WindowPageOffsetX();
1804 [Data(Description = "Configure this client to retrieve the page's vertical scroll offset", Submenu = "Window")]
1805 IAllowPuppeteerExecution WindowPageOffsetY();
1806 [Data(Description = "Configure this client to retrieve the browser window's screen X position", Submenu = "Window")]
1807 IAllowPuppeteerExecution WindowScreenLeft();
1808 [Data(Description = "Configure this client to retrieve the browser window's screen Y position", Submenu = "Window")]
1809 IAllowPuppeteerExecution WindowScreenTop();
1810 [Action(Description = "Configure this client to hover the mouse over the given element", Submenu = "Mouse")]
1811 IAllowPuppeteerExecution Hover(string elementId);
1812 [Data(Description = "Configure this client to evaluate the given XPath expression and return the first matching node", Submenu = "Find Elements")]
1813 IAllowPuppeteerExecution Evaluate(string xpath);
1814 [Data(Description = "Configure this client to evaluate the given XPath expression and return all matching nodes", Submenu = "Find Elements")]
1815 IAllowPuppeteerExecution EvaluateAll(string xpath);
1816 [Data(Description = "Configure this client to find the first element matching the given CSS selector", Submenu = "Find Elements")]
1817 IAllowPuppeteerExecution QuerySelector(string css);
1818 [Data(Description = "Configure this client to find all elements matching the given CSS selector", Submenu = "Find Elements")]
1819 IAllowPuppeteerExecution QuerySelectors(string css);
1820 IAllowPuppeteerExecution ScrollWindow(int hPixels, int vPixels);
1821 [Action(Description = "Configure this client to clear any overridden HTTP referrer", Submenu = "Referrer and User Agent")]
1822 IAllowPuppeteerExecution ClearReferrer();
1823 [Browser(Description = "Configure this client to bring the browser window to the foreground", Submenu = "Windows")]
1824 IAllowPuppeteerExecution TopBrowser();
1825
1826
1827 // Multi-parameter methods with fluent steps
1828 IAllowPuppeteerExecution ScrollElement(int hPixels, int vPixels);
1829 [Action(Description = "Configure this client to set an attribute on the given element; combine with WithAttribute and WithValue to specify the attribute and value", Submenu = "Input")]
1830 IAllowPuppeteerAttribute SetAttribute(string elementId);
1831 [Data(Description = "Configure this client to set the value of a range input element; combine with WithRangeValue to specify the value", Submenu = "Keyboard")]
1832 IAllowPuppeteerRangeValue SetRange(string elementId);
1833 [Scroll(Description = "Configure this client to scroll the given element; combine with WithHPixels/WithVPixels to specify the scroll amount")]
1834 IAllowPuppeteerScrollElement ScrollElement(string elementId);
1835 [Action(Description = "Configure this client to start a drag from the given element; combine with WithDestElementId or WithDeltaX/WithDeltaY to set the drop target", Submenu = "Mouse")]
1836 IAllowPuppeteerDragAndDrop DragAndDrop(string elementId);
1837 [Data(Description = "Configure this client to retrieve an attribute from the given element; combine with WithAttribute to specify which attribute", Submenu = "Element")]
1838 IAllowPuppeteerAttribute GetAttribute(string elementId); // Returns IAllowRESTAttribute, skips WithValue}
1839 }
1846 #endregion Puppeteer
1847 #region GPAL URL
1851 public interface IAllowGPALUrlForUrl : IAllowToGPALObject<IGPALUrl>
1852 {
1856 [Settings(Description = "Sets the target URL (blank or null becomes https://google.com)")]
1858 }
1859
1863 public interface IAllowGPALUrlStorageType : IAllowToGPALObject<IGPALUrl>
1864 {
1868 [Settings(Description = "Start declaring the storage action with storage type first")]
1870 }
1871
1875 public interface IAllowGPALUrlStorageItemConfig : IAllowGPALUrlStorageType, IAllowToGPALObject<IGPALUrl>
1876 {
1880 [Browser(Description = "Optional: domain override")]
1882
1886 [Browser(Description = "For indexedDb, this is the 'table' the object store, they call it a store name")]
1888
1892 [Browser(Description = "Optional: path (e.g. cookie path, object store name)")]
1894
1898 [Browser(Description = "Specific key for the current storage type")]
1900
1904 [Settings(Description = "User defined data, strictly used for filtering in GPAL")]
1913 [Settings(Description = "Delete the storage on every origin, not only the current one (OttoMagic only)")]
1915 }
1916
1921 {
1925 [Browser(Description = "Optional: domain override")]
1927 }
1928
1932 public interface IGPALUrl :
1937 {
1941 string Url { [Data(Description = "The target URL (never null)")] get; }
1942
1943 [Action(Description = "Adds a fully-configured StorageAction to the list")]
1944 List<StorageAction> Add(StorageAction storageAction);
1945 [Action(Description = "Adds multiple fully-configured StorageAction items")]
1946 List<StorageAction> Add(List<StorageAction> storageActions);
1947
1951 [Data(Description = "List of storage actions to perform before navigation")]
1952 IReadOnlyList<StorageAction> GetActions();
1953 }
1954 #endregion GPAL URL
1955}
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,...