17using DocumentFormat.OpenXml.Office.CustomUI;
22using OpenQA.Selenium.Remote;
24using System.Collections;
25using System.Collections.Generic;
26using System.Data.SqlClient;
27using System.Diagnostics;
29using System.Drawing.Imaging;
33using System.Runtime.CompilerServices;
35using System.Threading.Tasks;
36using System.Windows.Automation;
37using System.Windows.Forms;
50 private static Stopwatch _appTimer;
51 private static DateTime _startTime;
53 #region <Virtual Keys>
58 public static byte VK_ALT { [Keys()]
get {
return 0x12; } }
62 public static byte VK_DELETE { [Keys()]
get {
return 0x2e; } }
66 public static byte VK_F10 { [Keys()]
get {
return 0x79; } }
70 public static byte VK_PRIOR { [Keys()]
get {
return 0x21; } }
74 public static byte VK_NEXT { [Keys()]
get {
return 0x22; } }
78 public static byte VK_END { [Keys()]
get {
return 0x23; } }
82 public static byte VK_HOME { [Keys()]
get {
return 0x24; } }
86 public static byte VK_DOWN { [Keys()]
get {
return 0x28; } }
90 public static byte VK_UP { [Keys()]
get {
return 0x26; } }
94 public static byte VK_TAB { [Keys()]
get {
return 0x09; } }
98 public static byte VK_RETURN { [Keys()]
get {
return 0x0D; } }
118 public static byte VK_LWIN { [Keys()]
get {
return 0x5B; } }
122 public static byte VK_RWIN { [Keys()]
get {
return 0x5C; } }
130 public static byte VK_LMENU {
get {
return 0xA4; } }
134 public static byte VK_RMENU {
get {
return 0xA5; } }
138 public static byte VK_APPS {
get {
return 0x5D; } }
142 public static byte VK_SPACE { [Keys()]
get {
return 0x20; } }
146 public static byte VK_BACK { [Keys()]
get {
return 0x08; } }
172 #endregion <Virtual Keys>
173 #region <Working Variables>
174 private static List<
Application.
Application> ApplicationList {
get; } =
new List<Application.Application>();
175 private static List<Browser.Browser> BrowserList {
get; } =
new List<
Browser.Browser>();
176 private static List<Selector> SelectorList {
get; } =
new List<Selector>();
177 private static List<GPALForm.GPALForm> FormList {
get; } =
new List<GPALForm.GPALForm>();
178 private static List<IGPALAI> AIList {
get; } =
new List<IGPALAI>();
179 private static List<GPALFile> FileList {
get; } =
new List<GPALFile>();
180 private static List<IGPALMail> MailList {
get; } =
new List<IGPALMail>();
181 public static List<IGPALLogger> LoggerList {
get; } =
new List<IGPALLogger>();
182 private static List<GPALControl> ControlList {
get; } =
new List<GPALControl>();
183 private static List<IGPALGrid<string>> GridList {
get; } =
new List<IGPALGrid<string>>();
185 private static bool SettingsLoaded
189 return gpalSettings.SettingsLoaded;
194 gpalSettings.SettingsLoaded = value;
198 private static GPALSettings gpalSettings =
new GPALSettings(
true);
199 private static string _settingsFilePath =
"GPAL.yaml";
200 public static GPALSettings GPALSettings
208 gpalSettings = value;
211 private static Browser.ElementAssistant elementAssistant {
get; } =
new Browser.ElementAssistant();
212 private static Application.ElementAssistant applicationElementAssistant {
get; } =
new Application.ElementAssistant();
214 private static Browser.Browser tmpBrowser {
get;
set; } =
null;
215 private static Application.Application tmpApplication {
get;
set; } =
null;
216 private static bool UncaughtExceptionHandlerSet {
get;
set; } =
false;
218 private static int applicationCount = 1;
219 private static int browserCount = 1;
220 private static int selectorCount = 1;
221 private static int formCount = 1;
222 private static int controlCount = 1;
223 private static int executableCount = 1;
224 private static int restClientCount = 1;
226 private static readonly
string applicationName =
"Application";
227 private static readonly
string browserName =
"Browser";
228 private static readonly
string chartName =
"Chart";
229 private static readonly
string selectorName =
"Selector";
230 private static readonly
string formName =
"Form";
231 private static readonly
string buttonName =
"Button";
232 private static readonly
string checkboxName =
"Checkbox";
233 private static readonly
string inputName =
"Input";
234 private static readonly
string labelName =
"Label";
235 private static readonly
string radioButtonName =
"Radiobutton";
236 private static readonly
string textAreaName =
"TextArea";
237 private static readonly
string richTextBoxName =
"RichTextBox";
238 private static readonly
string executableName =
"Executable";
239 private static readonly
string restClientName =
"RESTClient";
241 private static bool inPublishEvent =
false;
244 [ThreadStatic]
private static HashSet<IGPALLogger> loggersWriting;
245 #endregion <Working Variables>
247 static bool inStaticInit =
false;
257 if (
false == inStaticInit)
262 _startTime = DateTime.Now;
263 _appTimer = Stopwatch.StartNew();
267 if (ConsoleEvents.HasFlag(GPALEventType.INFO))
270 PublishSimpleEvent(GPALEventType.INFO, $
">>> Application Start Time: [{_startTime.ToString("yyyy-MM-dd HH:mm:ss
")}] <<<");
272 else if (ConsoleEvents.HasFlag(GPALEventType.NOTICE))
275 PublishSimpleEvent(GPALEventType.NOTICE, $
">>> Application Start Time: [{_startTime.ToString("yyyy-MM-dd HH:mm:ss
")}] <<<");
278 SetCatchUncaughtExceptions();
280 inStaticInit =
false;
283 #endregion Constructor
284 #region <Exception & Information EventHandler>
294 public Enums.GPALEventType GPALEventType {
get;
set; }
352 public IGPALGrid<string>
Tokens {
get;
set; }
364 public dynamic
Data {
get;
set; }
371 internal static EventHandler<GPALEventArgs> ExceptionEventHandler {
get;
set; }
372 internal static EventHandler<GPALEventArgs> InformationEventHandler {
get;
set; }
373 #endregion <Exception & Information EventHandler>
394 internal static EventHandler<GPALEventArgs> ExceptionHandler
398 return ExceptionEventHandler;
421 internal static EventHandler<GPALEventArgs> InformationHandler
425 return InformationEventHandler;
429 #region <GPAL Object Getters>
430 public static Cryptography Cryptography
432 get =>
new Cryptography();
434 public static Base64Helper Base64Helper
436 get =>
new Base64Helper();
471 public static void RegisterOCR(Func<OCRInterfaces.IGPALOCR> factory) => _ocrFactory = factory;
474 : throw new InvalidOperationException(
"OCR provider not registered. Add the GenerallyPositive.OCR NuGet and call GPAL.RegisterOCR(() => new GPALOCR()).");
481 if (
null == imageHelper)
520 public static IAllowGridActions<string>
Grid
525 IGPALGrid<string> grid =
new GPALGrid<string>();
539 LoggerList.Add(logger);
561 [Fluent(Description =
"")]
591 tmpApplication.Name = applicationName + applicationCount++.ToString();
592 ApplicationList.Add(tmpApplication);
593 return tmpApplication;
621 tmpBrowser =
new Browser.Browser();
622 tmpBrowser.Name = browserName + browserCount++.ToString();
627 if (0 < BrowserList.Count)
628 tmpBrowser.WithAutomationEngine(BrowserList[0].AutomationEngine);
630 BrowserList.Add(tmpBrowser);
698 if (
null != tmpBrowser)
699 tmpSelector =
new Selector(tmpBrowser);
700 else if (
null != tmpApplication)
701 tmpSelector =
new Selector(tmpApplication);
704 tmpSelector.Name = selectorName + selectorCount++.ToString();
705 SelectorList.Add(tmpSelector);
738 Name = executableName + executableCount++.ToString()
920 Name = restClientName + restClientCount++.ToString()
936 get =>
new Gherkin();
965 #region Internal GPAL factory for ActivatorHelper
966 internal static GPALElement Element
968 get =>
new GPALElement();
970 internal static GPALFileSettings FileSettings
972 get =>
new GPALFileSettings();
974 internal static GPALMailSettings MailSettings
976 get =>
new GPALMailSettings();
978 internal static GPALSettings Settings
980 get =>
new GPALSettings();
982 #endregion Internal GPAL factory for ActivatorHelper
983 #endregion <GPAL Objects>
984 #region Shorthand Helpers
986 public static IGPALExcel ExcelFor(GPALFile excelFile)
988 return new GPALExcel().WithFile(excelFile).ToGPALObject();
992 public static ICredentials CredentialsFor(CredentialServiceType credentialServiceType)
997 public static IGoogleSheets GoogleSheetsFor(
string spreadsheetName)
999 return new GoogleSheets().WithSpreadsheet(spreadsheetName).ToGPALObject();
1002 public static IGoogleDrive GoogleDriveFor(ICredentials credentials)
1004 return new GoogleDrive().WithCredentials(credentials).ToGPALObject();
1007 public static IGPALGrid<T> GridForType<T>()
1009 return new GPALGrid<T>();
1028 if (
null != selectorName)
1029 return Selector.WithCSS(css).WithSelectorName(selectorName).ToGPALObject();
1031 return Selector.WithCSS(css).ToGPALObject();
1035 public static Selector XPathSelector(
string xpath,
string selectorName =
null)
1037 if (
null != selectorName)
1043 public static GPALFile FileFor(
string path)
1045 return File.WithFileName(path).ToGPALObject();
1049 public static IBrowser BrowserGet(GPALUrl url)
1057 public static IBrowser BrowserGoto(GPALUrl url)
1064 public static GPALButton ButtonFor(
string text)
1066 var c =
new GPALButton { Name = buttonName + controlCount++.ToString() };
1067 c.IsDefault =
false;
1073 public static GPALLabel LabelFor(
string text)
1075 var c =
new GPALLabel { Name = labelName + controlCount++.ToString() };
1081 public static GPALInput InputFor(
string text =
"")
1083 var c =
new GPALInput { Name = inputName + controlCount++.ToString() };
1089 public static GPALTextArea TextAreaFor(
string text =
"")
1091 var c =
new GPALTextArea { Name = textAreaName + controlCount++.ToString() };
1097 public static GPALRichTextBox RichTextBoxFor(
string text =
"")
1099 var c =
new GPALRichTextBox { Name = richTextBoxName + controlCount++.ToString() };
1105 public static GPALCheckbox CheckboxFor(
string text,
bool isChecked =
false)
1107 var c =
new GPALCheckbox { Name = checkboxName + controlCount++.ToString() };
1109 c.IsChecked = isChecked;
1114 public static GPALRadioButton RadioButtonFor(
string text,
bool isChecked =
false)
1116 var c =
new GPALRadioButton { Name = radioButtonName + controlCount++.ToString() };
1118 c.IsChecked = isChecked;
1123 public static GPALTab TabFor(
string text)
1125 var c =
new GPALTab { Name = radioButtonName + controlCount++.ToString() };
1131 public static GPALChart ChartFor(
string title =
"")
1133 var c =
new GPALChart { Name = chartName + controlCount++.ToString() };
1134 if (!
string.IsNullOrEmpty(title)) c.WithTitle(title);
1139 public static GPALComboBox ComboBoxFor(params
string[] items)
1141 var c =
new GPALComboBox { Name =
"ComboBox" + controlCount++.ToString() };
1142 if (items !=
null && items.Length > 0) c.WithItems(items);
1146 public static GPALDataGridView DataGridViewFor(params
string[] columns)
1148 var c =
new GPALDataGridView { Name =
"DataGridView" + controlCount++.ToString() };
1149 if (columns !=
null && columns.Length > 0) c.WithColumns(columns);
1153 public static GPALListView ListViewFor(params
string[] columns)
1155 var c =
new GPALListView { Name =
"ListView" + controlCount++.ToString() };
1156 if (columns !=
null && columns.Length > 0) c.WithColumns(columns);
1160 public static GPALProgressBar ProgressBarFor(
int maximum = 100)
1162 var c =
new GPALProgressBar { Name =
"ProgressBar" + controlCount++.ToString() };
1163 c.WithMaximum(maximum);
1167 public static GPALStatusStrip StatusStripFor(
string text =
"Ready")
1169 var c =
new GPALStatusStrip { Name =
"StatusStrip" + controlCount++.ToString() };
1174 public static GPALNumericUpDown NumericUpDownFor(decimal minimum = 0, decimal maximum = 100)
1176 var c =
new GPALNumericUpDown { Name =
"NumericUpDown" + controlCount++.ToString() };
1177 c.WithMinimum(minimum);
1178 c.WithMaximum(maximum);
1182 public static GPALDateTimePicker DateTimePickerFor(DateTime? value =
null)
1184 var c =
new GPALDateTimePicker { Name =
"DateTimePicker" + controlCount++.ToString() };
1185 if (value.HasValue) c.WithValue(value.Value);
1189 public static GPALTreeView TreeViewFor()
1191 return new GPALTreeView { Name =
"TreeView" + controlCount++.ToString() };
1194 public static GPALFileSelector FileSelectorFor(
string title =
"Select File/Folder")
1196 var c =
new GPALFileSelector { Name =
"FileSeleector" + controlCount++.ToString() };
1201 public static GPALTableLayoutPanel TableLayoutPanelFor(
int columns = 1,
int rows = 1)
1203 var c =
new GPALTableLayoutPanel { Name =
"TableLayoutPanel" + controlCount++.ToString() };
1204 c.WithColumnCount(columns);
1205 c.WithRowCount(rows);
1208 #endregion Shorthand Helpers
1209 #region <ElementAssitant>
1235 elementAssistant.Browser = selector.
Browser;
1236 elementAssistant.ForSelector(selector);
1237 return elementAssistant;
1266 applicationElementAssistant.Application = application;
1267 return applicationElementAssistant;
1269 #endregion <ElementAssitant>
1270 #region <Form Controls>
1308 FormName = formName + formCount++.ToString(),
1310 FormList.Add(tmpForms);
1353 Name = buttonName + controlCount++.ToString(),
1357 tmpControl.IsDefault =
false;
1358 ControlList.Add(tmpControl);
1410 Name = chartName + controlCount++.ToString()
1412 ControlList.Add(tmpControl);
1453 Name = checkboxName + controlCount++.ToString()
1455 ControlList.Add(tmpControl);
1491 Name =
"ComboBox" + controlCount++.ToString()
1519 Name =
"DataGridView" + controlCount++.ToString()
1548 Name =
"DateTimePicker" + controlCount++.ToString()
1600 Name =
"FileSeleector" + controlCount++.ToString()
1632 Name = inputName + controlCount++.ToString()
1634 ControlList.Add(tmpControl);
1664 Name = labelName + controlCount++.ToString()
1666 ControlList.Add(tmpControl);
1703 Name =
"ListView" + controlCount++.ToString()
1734 Name =
"NumericUpDown" + controlCount++.ToString()
1765 Name =
"ProgressBar" + controlCount++.ToString()
1815 Name = radioButtonName + controlCount++.ToString()
1817 ControlList.Add(tmpControl);
1843 Name =
"StatusStrip" + controlCount++.ToString()
1873 Name =
"MenuBar" + controlCount++.ToString()
1900 Name =
"BarItem" + controlCount++.ToString()
1926 Name =
"Toolbar" + controlCount++.ToString()
1962 Name = radioButtonName + controlCount++.ToString()
1964 ControlList.Add(tmpControl);
2026 Name = textAreaName + controlCount++.ToString()
2028 ControlList.Add(tmpControl);
2060 Name = richTextBoxName + controlCount++.ToString()
2062 ControlList.Add(tmpControl);
2091 Name =
"TreeView" + controlCount++.ToString()
2096 #endregion <Form Controls>
2097 #region <Getters/Setters>
2098 public static bool UseHardware
2100 get => gpalSettings.UseHardware;
2102 public static bool UseJavaSCript
2104 get => gpalSettings.UseJavaScript;
2126 return new Browser.WorkflowScheduler();
2150 return new Browser.GPALHiddenDesktops();
2153 public static string Version
2166 return gpalSettings.OAuthTokenUrl;
2170 gpalSettings.OAuthTokenUrl = value;
2173 internal static List<IGPALLogger> PublishToLoggers
2180 internal static bool PublishToConsole
2184 return GPALSettings.PublishToConsole;
2188 GPALSettings.PublishToConsole = value;
2191 internal static bool PublishToDebug
2195 return GPALSettings.PublishToDebug;
2198 internal static GPALEventType ConsoleEvents
2200 get => GPALSettings.ConsoleEvents;
2201 set => GPALSettings.ConsoleEvents = value;
2203 internal static GPALEventType DebugEvents
2205 get => GPALSettings.DebugEvents;
2207 internal static bool PublishStackTrace
2211 return GPALSettings.PublishStackTrace;
2214 internal static string ErrorPlaceholder
2218 return GPALSettings.ErrorPlaceholder;
2221 internal static string DriverLocation
2225 return GPALSettings.DriverLocation;
2228 internal static bool SimulateMouse
2232 return GPALSettings.SimulateMouse;
2235 internal static string TempProfileDirectory
2239 return GPALSettings.TempProfileDirectory;
2242 internal static List<
Browser.Browser> Browsers
2249 internal static int MatchingPercentage
2253 return GPALSettings.MatchingPercentage;
2256 internal static int TypingDelay
2260 return GPALSettings.TypingDelay;
2263 internal static bool StopOnNotFound
2267 return GPALSettings.StopOnNotFound;
2270 internal static bool NoFallbackRecoveryActions
2274 return gpalSettings.NoFallbackRecoveryActions;
2277 #endregion <Getters/Setters>
2280 public static void LoadSettings(GPALFile settingsFile =
null)
2282 bool hold = GPAL.PublishToConsole;
2283 GPALEventType events = GPAL.GPALSettings.ConsoleEvents;
2287 if (settingsFile !=
null)
2289 _settingsFilePath = settingsFile.Filenames[0];
2290 SettingsLoaded =
false;
2293 if (
false == SettingsLoaded)
2295 SettingsLoaded =
true;
2296 string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
2297 GPALFile resolvedFile = _settingsFilePath;
2299 if (
true == System.IO.File.Exists(resolvedFile.
Filenames[0]))
2302 GPAL.Converter.WithInput(resolvedFile).SaveTo(ref gpalSettings);
2304 hold = GPAL.PublishToConsole;
2305 events = GPAL.GPALSettings.ConsoleEvents;
2308 if (
"1" == Environment.GetEnvironmentVariable(
"GPAL_IS_SILENT"))
2309 GPAL.PublishToConsole =
false;
2311 GPAL.PublishSimpleEvent(GPALEventType.INFO, $
"[{resolvedFile.Filenames[0]}] loaded, using settings.", gpalSettings, GPALObjectType.Other);
2313 if (
false == gpalSettings.Version.Equals(currentVersion))
2315 GPAL.PublishSimpleEvent(GPALEventType.INFO, $
"[{resolvedFile.Filenames[0]}] updated to current GPAL version [{currentVersion}].", gpalSettings, GPALObjectType.Other);
2316 gpalSettings.Version = currentVersion;
2322 GPAL.PublishSimpleEvent(GPALEventType.WARNING, $
"[{resolvedFile.Filenames[0]}] does not exist. Using default settings and creating GPAL.yaml.", gpalSettings, GPALObjectType.Other);
2327 AIProvidersConfig.TryAutoLoad();
2329 catch (Exception ex)
2331 GPAL.PublishSimpleEvent(GPALEventType.EXCEPTION, $
"[{_settingsFilePath}] load error. Try deleting it and restarting.", gpalSettings, GPALObjectType.Other, ex);
2335 GPAL.PublishToConsole = hold;
2336 GPAL.GPALSettings.ConsoleEvents = events;
2340 public static void SaveSettings(GPALFile settingsFile =
null)
2342 if (settingsFile !=
null) _settingsFilePath = settingsFile.Filenames[0];
2343 GPAL.Converter.WithInput(GPALSettings).SaveTo((GPALFile)_settingsFilePath);
2355 ((ImageHelper)GPAL.ImageHelper).
CaptureScreen(browser).ToBitmap(out ((
Browser.Browser)browser).BrowserSettings.ScreenShot);
2372 [MethodImpl(MethodImplOptions.NoInlining)]
2376 var st =
new StackTrace();
2377 var sf = st.GetFrame(1);
2378 string name = sf.GetMethod().Name;
2380 if (name.Equals(
"MoveNext"))
2383 name = sf.GetMethod().ReflectedType.Name
2384 .Split(
new char[] {
'<',
'>' }, StringSplitOptions.RemoveEmptyEntries)[0];
2404 [MethodImpl(MethodImplOptions.NoInlining)]
2406 public static void PublishSimpleEvent(GPALEventType gPALEventType,
string msg, dynamic gPALObject =
null, Enums.GPALObjectType gPALObjectType = GPALObjectType.None, Exception ex =
null)
2413 bool handlerWants = (
null != ExceptionHandler ||
null != InformationHandler);
2414 bool consoleWants =
true == GPAL.PublishToConsole && gpalSettings.ConsoleEvents.HasFlag(gPALEventType);
2415 bool debugWants =
true == GPAL.PublishToDebug && gpalSettings.DebugEvents.HasFlag(gPALEventType);
2416 bool loggerWants = 0 < GPAL.PublishToLoggers.Count;
2418 if (
false == handlerWants &&
false == consoleWants &&
false == debugWants &&
false == loggerWants)
2421 if (
null != ExceptionHandler ||
null != InformationHandler ||
true == GPAL.PublishToConsole ||
true == GPAL.PublishToDebug ||
true == loggerWants)
2423 var st =
new StackTrace();
2424 var sf = st.GetFrame(1);
2425 string name = sf.GetMethod().Name;
2426 DateTime dateTime = DateTime.Now;
2427 string stackTrace =
null != ex &&
true == GPAL.PublishStackTrace ? $
"[{ex.StackTrace}]" :
string.Empty;
2429 if (name.Equals(
"MoveNext"))
2432 name = sf.GetMethod().ReflectedType.Name
2433 .Split(
new char[] {
'<',
'>' }, StringSplitOptions.RemoveEmptyEntries)[0];
2436 string outMessage = $
"[{dateTime.ToString("yyyy-MM-dd HH:mm:ss.ffff
")}][{gPALEventType}][{name}]: {msg}";
2440 if (GPALEventType.ERROR == gPALEventType || GPALEventType.EXCEPTION == gPALEventType)
2441 if (
false == inPublishEvent &&
false == handlingTermination)
2445 inPublishEvent =
true;
2446 if (
true == gpalSettings.TakeEventScreenshot)
2447 if (typeof(
Browser.Browser) == gPALObject?.GetType())
2448 ((ImageHelper)GPAL.ImageHelper).
CaptureScreen(gPALObject).ToBitmap(out ss);
2450 ((ImageHelper)GPAL.ImageHelper).CaptureScreen().ToBitmap(out ss);
2460 inPublishEvent =
false;
2466 GPALEventType = gPALEventType,
2467 GPALObject = gPALObject,
2468 GPALObjectType = gPALObjectType,
2469 CurrentUOW = (Enums.GPALObjectType.UnitOfWork == gPALObjectType ? (
UnitOfWork)gPALObject :
null),
2470 Message = $
"{name}: {msg}",
2472 ExceptionRaised = ex,
2473 Data = (Enums.GPALObjectType.Converter == gPALObjectType ? gPALObject :
string.Empty),
2474 DateTimeStamp = dateTime
2478 if (
true == handlerWants)
2481 ExceptionHandler?.Invoke(gPALObject, args);
2483 InformationHandler?.Invoke(gPALObject, args);
2486 if (
true == GPAL.PublishToConsole)
2489 if (gpalSettings.ConsoleEvents.HasFlag(gPALEventType) && Environment.GetEnvironmentVariable(
"GPAL_IS_SILENT") !=
"1")
2491 Console.WriteLine(outMessage);
2495 if (
null != ex && gpalSettings.ConsoleEvents.HasFlag(GPALEventType.DEBUG))
2496 Console.WriteLine($
"[{ex.Message}]{stackTrace}");
2500 if (
true == GPAL.PublishToDebug)
2502 if (gpalSettings.DebugEvents.HasFlag(gPALEventType) && Environment.GetEnvironmentVariable(
"GPAL_IS_SILENT") !=
"1")
2504 Debug.WriteLine(outMessage);
2507 if (
null != ex && gpalSettings.DebugEvents.HasFlag(GPALEventType.DEBUG))
2508 Debug.WriteLine($
"[{ex.Message}]{stackTrace}");
2516 if (0 < GPAL.PublishToLoggers.Count &&
true == Enum.TryParse(gPALEventType.ToString(), out Enums.LogType logType))
2518 if (
null == loggersWriting)
2519 loggersWriting =
new HashSet<IGPALLogger>();
2522 foreach (
IGPALLogger logger
in GPAL.PublishToLoggers.ToList())
2527 if (
true == loggersWriting.Contains(logger))
2532 loggersWriting.Add(logger);
2540 writer.Log(msg, name, logType);
2547 writer.Log($
"[{ex.Message}]{stackTrace}", name, Enums.LogType.DEBUG);
2555 loggersWriting.Remove(logger);
2562 if (Environment.GetEnvironmentVariable(
"GPAL_IS_SILENT") !=
"1")
2564 Console.Out.Flush();
2582 IDictionary<(TRow row, TCol col), TValue> data,
2583 string cornerLabel =
"",
2584 Func<TValue, string> formatCell =
null,
2585 string emptyCell =
"-")
2587 if (
null == data || 0 == data.Count)
2590 formatCell = formatCell ?? (v => v?.ToString() ??
string.Empty);
2592 var rows = data.Keys.Select(k => k.row).Distinct().OrderBy(r => r, Comparer<TRow>.Default).ToList();
2593 var cols = data.Keys.Select(k => k.col).Distinct().OrderBy(c => c, Comparer<TCol>.Default).ToList();
2595 string Cell(TRow r, TCol c) => data.TryGetValue((r, c), out var v) ? formatCell(v) : emptyCell;
2597 int rowHeaderWidth = cornerLabel.Length;
2598 foreach (var r
in rows)
2599 rowHeaderWidth = Math.Max(rowHeaderWidth, (r?.ToString() ??
string.Empty).Length);
2601 var colWidth =
new Dictionary<TCol, int>();
2602 foreach (var c
in cols)
2604 int w = (c?.ToString() ??
string.Empty).Length;
2605 foreach (var r
in rows)
2606 w = Math.Max(w, Cell(r, c).Length);
2610 var sb =
new StringBuilder();
2612 sb.AppendLine($
"=== {title} ===");
2614 sb.Append(cornerLabel.PadRight(rowHeaderWidth));
2615 foreach (var c
in cols)
2616 sb.Append(
" | " + (c?.ToString() ??
string.Empty).PadRight(colWidth[c]));
2619 sb.Append(
new string(
'-', rowHeaderWidth));
2620 foreach (var c
in cols)
2621 sb.Append(
"-+-" +
new string(
'-', colWidth[c]));
2624 foreach (var r
in rows)
2626 sb.Append((r?.ToString() ??
string.Empty).PadRight(rowHeaderWidth));
2627 foreach (var c
in cols)
2628 sb.Append(
" | " + Cell(r, c).PadRight(colWidth[c]));
2641 public static void EmitRuntimeTable(
string title, IDictionary<(BrowserType bt, AutomationEngine ae), TimeSpan> runtimes)
2642 => EmitTable(title +
" runtime (min:sec.ms)", runtimes,
"Browser",
2643 ts => $
"{(int)ts.TotalMinutes}:{ts.Seconds:D2}.{ts.Milliseconds:D3}");
2644 #endregion <Helpers>
2645 #region <GPAL Settings>
2659 gpalSettings.AppCallIfFoundList.Add(callIfFound);
2669 gpalSettings.AppCallIfNotFoundList.Add(callIfNotFound);
2679 gpalSettings.CallIfFoundList.Add(callIfFound);
2689 gpalSettings.CallIfNotFoundList.Add(callIfNotFound);
2697 [
GPALSettings(Description =
"Print specified GPAL events to the console. [none (default)]")]
2698 public static IAllowGPALSettings WithPublishToConsole(GPALEventType eventType = GPALEventType.INFO | GPALEventType.WARNING | GPALEventType.ERROR | GPALEventType.EXCEPTION | GPALEventType.NOTICE | GPALEventType.CAUTION | GPALEventType.FAILURE)
2700 GPALSettings.ConsoleEvents = eventType;
2701 if (GPALEventType.NONE == eventType)
2702 GPALSettings.PublishToConsole =
false;
2704 GPALSettings.PublishToConsole =
true;
2712 [
GPALSettings(Description =
"Print specified GPAL events to the output window in VisualStudio. [none (default)]")]
2713 public static IAllowGPALSettings WithPublishToDebug(GPALEventType eventType = GPALEventType.INFO | GPALEventType.WARNING | GPALEventType.ERROR | GPALEventType.EXCEPTION | GPALEventType.NOTICE | GPALEventType.CAUTION | GPALEventType.FAILURE)
2715 GPALSettings.DebugEvents = eventType;
2716 if (GPALEventType.NONE == eventType)
2717 GPALSettings.PublishToDebug =
false;
2719 GPALSettings.PublishToDebug =
true;
2729 [
GPALSettings(Description =
"Publish GPAL events to a logger, which writes them to whatever it was given: a file or a database.")]
2732 GPALSettings.WithPublishToLogger(logger);
2740 [
GPALSettings(Description =
"Stop publishing GPAL events to a logger that was previously given one.")]
2743 GPALSettings.RemoveLogger(logger);
2761 [
GPALSettings(Description =
"Which GPAL events reach an attached Information or Exception handler. [All (default)]")]
2764 GPALSettings.HandlerEvents = eventTypes;
2772 [
GPALSettings(Description =
"Print stack trace when PublishToConsole or PublishToDebug is true. [true (default)]")]
2775 GPALSettings.PublishStackTrace = trueFalse;
2787 [
GPALSettings(Description =
"Callback for failures a workflow can decide about, used by any browser without its own CallOnFail")]
2790 GPALSettings.CallOnFailHandlers.Add(callOnFail);
2799 [
GPALSettings(Description =
"Substitue string when data cannot be retrieved for an element [##UNABLE TO GET## (default)]")]
2802 GPALSettings.ErrorPlaceholder = message;
2811 [
GPALSettings(Description =
"Set the default timeout for waiting for a download to start.")]
2814 GPALSettings.DownloadTimeoutInSec = seconds;
2825 [
GPALSettings(
"DO NOT use GPAL fallback actions on failure, just fail. Usually involves javascript recovery attempt. [false (default)")]
2828 GPALSettings.NoFallbackRecoveryActions = trueFalse;
2838 GPALSettings.WithAllThatMatch = matchCount;
2850 GPALSettings.AutoUpdateWebDriver = trueFalse;
2861 GPALSettings.AutomationEngine = automationEngine;
2871 [
GPALSettings(Description =
"Global location for browser drivers. [./ (default)(same dir as exe)]")]
2885 [
GPALSettings(Description =
"Where GPAL writes files it created itself and nobody asked to keep. [GPALfilesSafeToDelete beside the exe (default)]")]
2896 internal static string TempDirectory()
2898 string tempPath =
true ==
string.IsNullOrWhiteSpace(
GPALSettings.TempDirectory)
2899 ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"GPALfilesSafeToDelete") +
@"\"
2902 if (
false == Directory.Exists(tempPath))
2903 Directory.CreateDirectory(tempPath);
2942 [GPALSettings(Description =
"Intercharacter typing delay ceiling [0ms (default), no pacing]")]
2945 GPALSettings.WithTypingDelay(delayInTicks);
2960 [
GPALSettings(Description =
"Image matching similarity percentage. [80 (default)]")]
2963 GPALSettings.WithImageMatchingPercentage(matchPercent);
2979 [
GPALSettings(Description =
"Simulate moving the mouse for every action (implies .WithHardware). [false (default)]")]
2982 GPALSettings.SimulateMouse = trueFalse;
3002 [
GPALSettings(Description =
"Stop workflow if any selector is not found")]
3005 GPALSettings.StopOnNotFound = trueFalse;
3009 [
GPALSettings(Description =
"Set the default location to store temporary profiles if browser.WithProfileDataDirectory is not used. default [C:\\profiles]")]
3010 public static IAllowGPALSettings WithTempProfileDirectory(
string tempProfileDirectory)
3012 GPALSettings.TempProfileDirectory = tempProfileDirectory;
3029 [GPALSettings(Description =
"Handler to receive GPAL Exception events")]
3032 ExceptionEventHandler = eventHandler;
3033 Exception ex =
new Exception(
"Welcome Exception :)");
3034 GPAL.PublishSimpleEvent(Enums.GPALEventType.EXCEPTION, $
"Welcome to GPAL [{Version}] Exception Channel",
null, Enums.GPALObjectType.None, ex);
3043 [
GPALSettings(Description =
"Print GPAL published information or exception messages to the output window in VisualStudio. [true (default)]")]
3046 GPALSettings.PromptBeforeUnexpectedExit = trueFalse;
3061 [
GPALSettings(Description =
"Handler to receive GPAL Information events")]
3064 InformationEventHandler = eventHandler;
3065 GPAL.PublishSimpleEvent(Enums.GPALEventType.INFO, $
"Welcome to GPAL [{Version}] Information Channel");
3082 GPALSettings.WaitForInMs = waitForInTicks;
3088 GPALSettings.TakeEventScreenshot = trueOrFalse;
3093 #endregion <GPAL Settings>
3096 private static void CheckVersions()
3098 if (
string.Empty.Equals(tmpBrowser?.BrowserVersion))
3100 BrowserType browserType = tmpBrowser.BrowserType;
3102 if (BrowserType.Chrome == browserType)
3104 DriverHelper.GetChromeVersion(out tmpBrowser.BrowserSettings.Version);
3106 else if (BrowserType.Edge == browserType)
3108 DriverHelper.GetEdgeVersion(out tmpBrowser.BrowserSettings.Version);
3110 else if (BrowserType.FireFox == browserType)
3112 DriverHelper.GetFirefoxVersion(out tmpBrowser.BrowserSettings.Version);
3142 private static void SetCatchUncaughtExceptions()
3144 if (
false == UncaughtExceptionHandlerSet)
3151 System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
3154 AppDomain.CurrentDomain.UnhandledException +=
3155 new UnhandledExceptionEventHandler(UncaughtExceptionHandler);
3158 Console.CancelKeyPress += OnCancelKeyPress;
3159 AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
3162 catch (Exception ex)
3164 PublishSimpleEvent(GPALEventType.EXCEPTION, $
"Unable to set uncaught exception handler",
null, Enums.GPALObjectType.None, ex);
3167 UncaughtExceptionHandlerSet =
true;
3171 private static bool handlingTermination =
false;
3172 private static void UncaughtExceptionHandler(
object sender, UnhandledExceptionEventArgs args)
3174 Exception e = (Exception)args.ExceptionObject;
3176 if (
false == handlingTermination)
3178 handlingTermination =
true;
3182 bool ours = e is GPALException;
3183 string reason =
true == ours ?
"GPAL exception" :
"uncaught exception";
3185 if (ConsoleEvents.HasFlag(GPALEventType.WARNING))
3187 PublishSimpleEvent(GPALEventType.WARNING, $
">>> Caught {reason}: [{e.Message}][{e.StackTrace}]",
null, Enums.GPALObjectType.None);
3188 PublishSimpleEvent(GPALEventType.WARNING, $
">>> [{reason}] Cleaning up before terminating.",
null, GPALObjectType.None);
3190 else if (ConsoleEvents.HasFlag(GPALEventType.CAUTION))
3192 PublishSimpleEvent(GPALEventType.CAUTION, $
">>> Caught {reason}: [{e.Message}][{e.StackTrace}]",
null, Enums.GPALObjectType.None);
3193 PublishSimpleEvent(GPALEventType.CAUTION, $
">>> [{reason}] Cleaning up before terminating.",
null, GPALObjectType.None);
3196 if (
false == PublishToConsole)
3197 GPAL.PublishSimpleEvent(GPALEventType.NOTICE, $
"Terminating due to [{reason}]: [{e.Message}]");
3199 if (
false == PublishToDebug)
3200 Debug.WriteLine($
"Terminating due to {reason}: [{e.Message}]");
3202 CleanupAndExit(
true == ours ?
"GPAL Exception" :
"Unhandled Exception");
3206 private static void OnCancelKeyPress(
object sender, ConsoleCancelEventArgs e)
3210 if (
false == handlingTermination)
3212 handlingTermination =
true;
3216 if (
false == PublishToConsole)
3217 GPAL.PublishSimpleEvent(GPALEventType.NOTICE, $
"Terminating due to Ctrl+C or Ctrl+Break.");
3219 if (
false == PublishToDebug)
3220 Debug.WriteLine($
"Terminating due to Ctrl+C or Ctrl+Break.");
3222 CleanupAndExit(
"Ctrl+C or Ctrl+Break");
3226 private static void OnProcessExit(
object sender, EventArgs e)
3230 if (
false == handlingTermination)
3232 handlingTermination =
true;
3234 if (
false == PublishToConsole)
3235 GPAL.PublishSimpleEvent(GPALEventType.NOTICE, $
"Terminating due to Process Exit or console X.");
3237 if (
false == PublishToDebug)
3238 Debug.WriteLine($
"Terminating due to Process Exit or console X.");
3240 CleanupAndExit(
"Process Exit or console X");
3244 private static bool _cleanupDone =
false;
3246 internal static void CleanupAndExit(
string reason)
3248 if (
false == _cleanupDone)
3250 _cleanupDone =
true;
3253 if (ConsoleEvents.HasFlag(GPALEventType.INFO))
3254 PublishSimpleEvent(GPALEventType.INFO, $
">>> [{reason}] Cleaning up before terminating.",
null, GPALObjectType.None);
3255 else if (ConsoleEvents.HasFlag(GPALEventType.NOTICE))
3256 PublishSimpleEvent(GPALEventType.NOTICE, $
">>> [{reason}] Cleaning up before terminating.",
null, GPALObjectType.None);
3258 if (
false == PublishToConsole)
3259 GPAL.PublishSimpleEvent(GPALEventType.NOTICE, $
"[{reason}] Cleaning up before terminating.");
3261 if (
false == PublishToDebug)
3262 Debug.WriteLine($
"[{reason}] Cleaning up before terminating.");
3264 BrowserHelper.KillAllRunningProcesses(
true,
null);
3268 GenerallyPositive.Browser.HiddenDesktop.CloseAll();
3270 catch (Exception ex)
3272 PublishSimpleEvent(GPALEventType.EXCEPTION, $
"Cleanup error",
null, GPALObjectType.None, ex);
3277 string endTime = DateTime.Now.ToString(
"yyyy-MM-dd HH:mm:ss");
3278 TimeSpan totalRuntime = _appTimer.Elapsed;
3279 string formattedRuntime = $
"{totalRuntime.Hours:D2}:{totalRuntime.Minutes:D2}:{totalRuntime.Seconds:D2}.{totalRuntime.Milliseconds:D3}";
3281 if (ConsoleEvents.HasFlag(GPALEventType.INFO))
3283 PublishSimpleEvent(GPALEventType.INFO, $
">>> Application End Time: [{endTime}] <<<",
null, GPALObjectType.None);
3284 PublishSimpleEvent(GPALEventType.INFO, $
">>> Total Runtime: [{formattedRuntime}] <<<",
null, GPALObjectType.None);
3286 else if (ConsoleEvents.HasFlag(GPALEventType.NOTICE))
3288 PublishSimpleEvent(GPALEventType.NOTICE, $
">>> Application End Time: [{endTime}] <<<",
null, GPALObjectType.None);
3289 PublishSimpleEvent(GPALEventType.NOTICE, $
">>> Total Runtime: [{formattedRuntime}] <<<",
null, GPALObjectType.None);
3296 if (
true == GPALSettings.PromptBeforeUnexpectedExit)
3298 GPAL.PublishSimpleEvent(GPALEventType.NOTICE,
"Press any key to exit...");
3299 Debug.WriteLine(
"Press any key to exit...");
3305 if (
true == reason.Equals(
"Process Exit or console X"))
3306 Environment.Exit(0);
3308 Environment.Exit(0xdead);
3310 #endregion <Private>
Application object that contains the fluent methods to create your Application workflow....
Browser object that contains the fluent methods to create your Browser workflow. Instatiated using G...
Represents a URL with optional pre-navigation storage cleanup / inspection actions....
Fluent YouTube video uploader. Entry point: GPAL.YouTube. Upload phase: WithCredentials -> WithTitle ...
File-side plumbing behind the fluent chain: writing a unit of work's data out in a delimited format,...
static string EnsureDirectoryEndsWithBackslash(string directoryPath)
Adds a trailing backslash to a directory path when it does not already have one, so the path can be c...
Used to pass objects of interest when publishing an Information or Exception Channel message NOTE: P...
List< GPALElement > WebElements
List of WebElements returned for the given Browser Selector.
IWebDriver BrowserDriver
The browser driver instantiated and used to connect to the browser.
IGPALGrid< string > Tokens
GPALGrid [rows/columns] of tokens being used to fill input.
string Message
The Message being published to the Information/Exception channel.
GPALElement GPALElement
The current web element.
SelectorSettings.SelectorPathEntry SelectorPathEntry
The SelectorPathEntry is the current path (css, xpath, text, image, etc) being evaluated/used to find...
SqlCommand SqlCommand
SqlCommand which threw an exception.
Exception ExceptionRaised
The Exception being published on the Exception channel.
Image ScreenShot
Every message is accompanied by an automatic screenshot in case this additional information provides ...
List< IGPALGrid< string > > TokenList
List of Grids associated with GPALFile.
UnitOfWork CurrentUOW
The Current Unit of Work for the GPALObject supplied. GPALObject (depending upon context) might also...
Selector Selector
The current Selector being used.
DateTime DateTimeStamp
The date/time this event is published.
AutomationElement AutomationElement
The current AutomationElement.
List< GPALAutomationElement > AutomationElements
List of AutomationElements returned for the given Application Selector.
Enums.GPALObjectType GPALObjectType
GPALObjectType enumeration: None, Application, Browser, GPALForm, UnitOfWork.
dynamic Data
Any type of data that does not fite in the above, converter data, for example.
dynamic GPALObject
Current context's Application, Browser, GPALForm, UnitOfWork object.
Class to define database usage. Currently only used for input from a table, sql or stored procedure....
Provides fluent, file-based automation of Excel workbooks: opening one or more workbooks (including w...
GPAL File object instantied with GPAL.File Used to load tokens into a GPALGrid [rows/columns].
List< string > Filenames
Get the list of filenames.
A read-only display control for rendering simple Markdown - headings (#, ##, ###),...
A GPAL multiline textare instantiated with GPAL.TextArea for use on GPAL forms. Callback EventHandle...
static byte VK_ALT
Alt key virtual keycode (VK) for use with keybd_event. https://docs.microsoft.com/en-us/windows/win32...
static IAllowProgressBarControlSettings ProgressBar
A progress bar control for GPAL forms. Displays task completion percentage or indeterminate (marquee...
static IAllowMenuBarControlSettings MenuBar
A menu bar docked to the top of a GPAL form. Open a top-level menu with WithMenu("TopMenu"),...
static IAllowGPALSettings WithNoFallbackActions(bool trueFalse=true)
GPAL has fallback alternatives for actions should they fail, generally applies to selenium....
static IAllowGPALSettings WithHandlerEvents(GPALEventType eventTypes)
Which event types reach the handlers given to WithInformationHandler and WithExceptionHandler....
static byte VK_END
End key virtual keycode (VK) for use with keybd_event.
static byte VK_F10
F10 key virtual keycode (VK) for use with keybd_event.
static IAllowGPALSettings RemoveLogger(IGPALLogger logger)
Stops publishing events to a logger.
static Browser.IHiddenDesktops HiddenDesktop
Every hidden desktop this process has made, and the screen itself. Peek puts one on the screen and pu...
static IAllowRichTextBoxControlSettings RichTextBox
Instantiates a new GPALRichTextBox for use on a GPAL form. Renders Markdown (headings,...
static IAllowApplicationOpenOrParameters Application
Instantiates a new fluent Application object.
static GPALSpliter SplitRight
Marks the end of a splitter's left pane. Everything added after it is the right pane.
static IAllowControlSettingsAndChartSettings Chart
Instantiates a new GPALChart for use on GPAL forms. Callback EventHandler is invoked on the GPALChar...
static IAllowLoggingSettings Logger
New GPAL Logger.
static IAllowSelectorSettings Selector
Instantiates a new fluent GPAL Selector object used to locate an element. Selectors are for browsers...
static IAllowGraphicSettings CaptureScreen(Browser.IBrowser browser)
Take a screenshot.
static IAllowGPALSettings WithPublishToDebug(GPALEventType eventType=GPALEventType.INFO|GPALEventType.WARNING|GPALEventType.ERROR|GPALEventType.EXCEPTION|GPALEventType.NOTICE|GPALEventType.CAUTION|GPALEventType.FAILURE)
Indicate which event types to print to the console. Default is none.
static IAllowControlSettingsAndEnabled TextArea
Instantiates a new GPALTextArea for use on a GPAL form. Callback EventHandler is invoked on the GPAL...
static IAllowConverterInput Converter
New GPAL Convertor.
static byte VK_LMENU
Left Alt key virtual keycode (VK) for use with keybd_event.
static IAllowGPALSettings WithInformationHandler(EventHandler< GPALEventArgs > eventHandler)
Set the handler to receive Information messages from GPAL which you might like to know about....
static void EmitTable< TRow, TCol, TValue >(string title, IDictionary<(TRow row, TCol col), TValue > data, string cornerLabel="", Func< TValue, string > formatCell=null, string emptyCell="-")
Emits an ASCII table for any 2-axis keyed dictionary as a single INFO event: row keys down the side,...
static GPALSpliter SplitBottom
Marks the end of a splitter's top pane. Everything added after it is the bottom pane.
static IAllowControlSettingsPlaceholderEnabledAndPassword Input
Instantiates a new one-line GPALInput control for use on a GPAL form. Callback EventHandler is invok...
static Browser.IAllowElementSetting ElementAssistant(Selector selector)
Instantiates a new Browser ElementAssistant object with fluent methods to help you manipulate WebElem...
static byte VK_BACK
Backspace key virtual keycode (VK) for use with keybd_event.
static IAllowGPALSettings CallIfFound(Browser.Browser.CallIfDelegate callIfFound)
Global Browser CallIfFound handler called for every selector in every Unit of Work.
static IAllowGPALSettings WithPublishStackTrace(bool trueFalse=true)
Print the stack trace along with the published GPAL message.
static IAllowToolbarControlSettings Toolbar
A toolbar docked below the menu bar, holding GPAL.BarItem buttons and optional separators.
static IAllowDateTimePickerControlSettings DateTimePicker
Instantiates a new GPALDateTimePicker for use on a GPAL form. Callback EventHandler is invoked on th...
static uint KEYEVENTF_EXTENDEDKEY
The extended-key flag indicates whether the keystroke message originated from one of the additional k...
static IAllowDatabaseSettings Database
Instantiates a new fluent Database SETTINGS object. This data object defines settings for use by ....
static byte VK_RWIN
Right Windows key virtual keycode (VK) for use with keybd_event.
static Application.IAllowForSelector ElementAssistant(Application.Application application)
Instantiates a new Application ElementAssistant with fluent methods to help you manipulate Automation...
static IAllowSplitterControlSettings Splitter
Instantiates a new GPALSplitter for use on a GPAL form: two panes with a bar between them,...
static IAllowFormSettings Form
Instantiates a new GPALForm for creating simple interactive user interfaces.
static IAllowGridActions< string > Grid
New GPALGrid<string></string> (rows/columns).
static IAllowControlSettingsEnabledAndChecked RadioButton
Instantiates a new GPALRadioButton for use on a GPAL form. Callback EventHandler is invoked on the G...
static IAllowComboBoxControlSettings ComboBox
Instantiates a new GPALComboBox for use on a GPAL form. Callback(s) set via WhenSelectedDo are invok...
static IAllowBarItemSettings BarItem
A single item shared by menu bars and toolbars: text, optional image, optional shortcut key,...
static string OAuthTokenUrl
Where an OAuth redirect lands and the token is read back from, e.g. http://localhost:3117/....
static byte VK_RETURN
Enter/Return key virtual keycode (VK) for use with keybd_event.
static byte VK_SCROLL
Scroll Lock key virtual keycode (VK) for use with keybd_event.
static byte VK_DOWN
Down Arrow key virtual keycode (VK) for use with keybd_event.
static IAllowDataGridViewControlSettings DataGridView
Instantiates a new GPALDataGridView for use on a GPAL form. Callback EventHandler is invoked on the ...
static IAllowGPALSettings AppCallIfFound(Application.Application.CallIfDelegate callIfFound)
Global Browser CallIfFound handler called for every selector in every Unit of Work.
static IAllowRequestSettings Request
Start describing an API request for .Fetch to issue from inside the page, so it carries the session t...
static IAllowRESTEndpoint RESTClient
Instantiate a new fluent RESTClient.
static IAllowGPALSettings WithPublishToLogger(IGPALLogger logger)
Print the published information or exception messages to the supplied database. Uses Database Create ...
static IAllowGPALSettings CallOnFail(Browser.Browser.CallOnFailDelegate callOnFail)
Add a handler to be called when something fails that the workflow is in a position to decide about,...
static byte VK_CONTROL_LEFT
Left Control key virtual keycode (VK) for use with keybd_event.
static byte VK_SHIFT_RIGHT
Right Shift key virtual keycode (VK) for use with keybd_event.
static string MyMethodName()
Returns the calling methods name (used in Information/Exception messages). Instead of harcoding meth...
static byte VK_SHIFT_LEFT
Left Shift key virtual keycode (VK) for use with keybd_event.
static IAllowControlSettingsAndFontSettings Label
Instantiates a new GPALLabel for use on a GPAL form. Callback EventHandler is invoked on the GPALLab...
static Selector CssSelector(string css, string selectorName=null)
Helper for shorthand notation.
static IAllowControlSettingsEnabledAndChecked Checkbox
Instantiates a new GPALCheckbox for use on a GPAL form. Callback EventHandler is invoked on the GPAL...
static IAllowGPALSettings WithExceptionHandler(EventHandler< GPALEventArgs > eventHandler)
Set the handler to receive handled Exception messages from GPAL. GPAL also sets an unhandled excepti...
static IAllowGPALSettings WithWaitFor(int waitForInTicks)
Global setting to wait for time in ticks for an element to show up. Applied to every element in every...
static IAllowGPALSettings AppCallIfNotFound(Application.Application.CallIfDelegate callIfNotFound)
Global Browser CallIfNotFound handler called for every selector in every Unit of Work.
static IAllowGPALSettings CallIfNotFound(Browser.Browser.CallIfDelegate callIfNotFound)
Global Browser CallIfNotFound handler called for every selector in every Unit of Work.
static IAllowTreeViewControlSettings TreeView
Instantiates a new GPALTreeView for use on a GPAL form. Callback EventHandler is invoked on the GPAL...
static byte VK_APPS
Application (Menu) key virtual keycode (VK) for use with keybd_event.
static byte VK_NEXT
Page Down key virtual keycode (VK) for use with keybd_event.
static void EmitRuntimeTable(string title, IDictionary<(BrowserType bt, AutomationEngine ae), TimeSpan > runtimes)
Convenience wrapper over EmitTable<TRow,TCol,TValue> for test-program bt/ae[/headless] loops: browser...
static IAllowGPALSettings WithAutoUpdateWebDriver(bool trueFalse=true)
Automatically download and unzip the web driver that matches the version of the browser being run....
static IAllowListVIewControlSettings ListView
Instantiates a new GPALListView for use on a GPAL form. Callback EventHandler is invoked on the GPAL...
static IAllowNumericUpDownControlSettings NumericUpDown
Instantiates a new GPALNumericUpDown for use on a GPAL form. Callback EventHandler is invoked on the...
static IAllowCredentialServiceType Credentials
Return a new credential manager.
static IAllowGPALSettings WithAutomationEngine(AutomationEngine automationEngine)
Set the automation type to use for all browsers. NOTE: can be overridden at the selector level (to ch...
static IAllowEmailServerSettings Mail
New GPAL Mail handler.
static IAllowGPALSettings WithStopOnNotFound(bool trueFalse=true)
Global setting instructing GPAL to terminate if any Selector cannot find any elements....
static IAllowGPALSettings WithPublishToConsole(GPALEventType eventType=GPALEventType.INFO|GPALEventType.WARNING|GPALEventType.ERROR|GPALEventType.EXCEPTION|GPALEventType.NOTICE|GPALEventType.CAUTION|GPALEventType.FAILURE)
Print the published information or exception messages to the console.
static IAllowGPALSettings WithImageMatchingPercentage(int matchPercent)
Sets the image matching percentage for image Selectors. .
static IAllowControlSettings Tab
Instantiates a new GPALTab for use on a GPAL form. Callback EventHandler is invoked on the GPALTab....
static byte VK_LWIN
Left Windows key virtual keycode (VK) for use with keybd_event.
static IAllowGPALSettings WithDefaultErrorPlaceholder(string message="##UNABLE TO GET##")
When GPAL is unable to retrieve data from an element, this message will be placed in the grid....
static IAllowGPALSettings WithDownloadTimeoutInSec(int seconds)
Set the default timeout time in seconds to wait for a download to start The default is 60 seconds.
static byte VK_UP
Up Arrow key virtual keycode (VK) for use with keybd_event.
static IAllowAIProvider AI
Entry point for the GPAL AI subsystem, providing a fluent interface for AI tasks.
static byte VK_SPACE
Space bar key virtual keycode (VK) for use with keybd_event.
static void PublishSimpleEvent(GPALEventType gPALEventType, string msg, dynamic gPALObject=null, Enums.GPALObjectType gPALObjectType=GPALObjectType.None, Exception ex=null)
Publish a message to either the information channel or exception channel (if exception passed in) Pub...
static byte VK_DELETE
Delete key virtual keycode (VK) for use with keybd_event.
static IAllowGPALSettings WithTempDirectory(string tempPath)
Where GPAL puts files it had to create but nobody asked to keep, such as a GPALFile given a url rathe...
static IAllowGPALSettings WithSimulateMouseMovement(bool trueFalse=true)
Global setting to simulate a human moving the mouse to the next point for all commands....
static IAllowStatusStripControlSettings StatusStrip
A status strip control (docked at the bottom) for GPAL forms. Displays real-time status messages,...
static IAllowControlSettingsEnabledAndDefault Button
Instantiates a new GPALButton for use on GPAL forms. Callback EventHandler is invoked on the GPALBut...
static IAllowDriveCredentials GoogleDrive
New GoogleDrive workflow.
static IAllowGroupBoxControlSettings GroupBox
Instantiates a new GPALGroupBox for use on a GPAL form: a titled box around a set of controls,...
static byte VK_PRIOR
Page Up key virtual keycode (VK) for use with keybd_event.
static Browser.IAllowScheduledWorkflow Workflow
Runs whole workflows at once, each building and owning whatever it drives, so one can run Chrome on O...
static IAllowGPALSettings WithAllThatMatch(int matchCount=int.MaxValue)
Global value for selector matches so it's not set UOW at a time.
static byte VK_TAB
Tab key virtual keycode (VK) for use with keybd_event.
static uint KEYEVENTF_KEYUP
Indicates a keyup keystroke is being sent. For use with keybd_event.
static IAllowGPALSettings WithDriverLocation(string driverPath)
The location of the browser drivers to be used for each GPAL.Browser instance. This can be overridde...
static IAllowBrowserTypeOrGoto Browser
Instantiates a new fluent Browser object.
static IAllowGPALSettings WithTypingDelay(int delayInTicks)
Sets the ceiling for the inter-character typing delay used by SendString across every automation engi...
static IAllowGPALSettings WithPromptBeforeUnexpectedExit(bool trueFalse=true)
Prompt 'Press any key...' before terminating due to an uncaught exception. GPAL tries to handle all e...
static byte VK_HOME
Home key virtual keycode (VK) for use with keybd_event.
static IAllowFileSelectorControlSettings FileSelector
Instantiates a new GPALFileSelector for use on a GPAL form. Opens a standard file or folder selectio...
static byte VK_RMENU
Right Alt key virtual keycode (VK) for use with keybd_event.
static byte VK_CONTROL_RIGHT
Right Control key virtual keycode (VK) for use with keybd_event.
static IAllowSpreadsheetSelection GoogleSheets
New Googlesheets workflow.
static IAllowFileName File
Instantiates a new fluent File SETTINGS object. This data object defines settings for use by the ....
Provides configurable logging to a file (in any format supported by GPALConverter) or to a GPALDataba...
Provides a fluent API for configuring, sending, and receiving email via SMTP, IMAP,...
Describes an API request for .Fetch to issue from inside the page, so it carries the session the brow...
Provides comprehensive image capture, conversion, and matching capabilities for automation scenarios....
GPAL Selector used to locate Application and Browser elements. Instantiated with GPAL....
Browser.Browser Browser
Browser associated with this selector.
IAllowSelectorSettings WithXPath(string xPath)
Define XPath used to find elements Both.
An entry defining a selector locator, a selector path.
Everything revolves around the Unit of Work. A Unit of Work is defined as one or more selectors betw...
Starting interface - only allows setting the target URL.
Every hidden desktop this process has made, and the screen itself. Peek and Return move the screen,...