Class GPAL
Everything starts here, all the GPAL controls and global settings using fluent syntax are here. GPAL cannot inherit any of the GPAL interfaces since it is a static class, but it does implement them, but will return some GPAL object or interface.
Inheritance
Inherited Members
Namespace: GenerallyPositive
Assembly: GPAL.dll
Syntax
public class GPAL
Properties
Application
Instantiates a new fluent Application object.
Declaration
public static IAllowApplicationOpenOrParameters Application { get; }
Property Value
| Type | Description |
|---|---|
| IAllowApplicationOpenOrParameters | Fluent interface to create your workflow |
Examples
Application application = (Application)GPAL.Application
.WithParameters(@"C:\edit.this.file.txt")
.Open(@"C:\Program File\Notepad++\notepad++.exe");
-or-
Application application = GPAL.Application
.WithParameters(@"C:\edit.this.file.txt")
.Open(@"C:\Program File\Notepad++\notepad++.exe")
.ToGPALObject();
Browser
Instantiates a new fluent Browser object.
Declaration
public static IAllowBrowserTypeOrGoto Browser { get; }
Property Value
| Type | Description |
|---|---|
| IAllowBrowserTypeOrGoto | Fluent interface to create your workflow |
Examples
Browser myBrowser = (Browser)GPAL.Browser
.WithBrowserType(BrowserType.Edge)
.WithDriverLocation(@"c:\drivers")
.GoTo("https://www.ebay.com/");
-or-
Browser myBrowser = GPAL.Browser
.WithBrowserType(BrowserType.Edge)
.WithDriverLocation(@"c:\drivers")
.GoTo("https://www.ebay.com/")
.ToGPALObject();
Button
Instantiates a new GPALButton for use on GPAL forms.
Callback EventHandler is invoked on the GPALButton.WindowsControl.Clicked event.
Declaration
public static IAllowControlSettingsEnabledAndDefault Button { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettingsEnabledAndDefault | Fluent interface to create your control |
Examples
static GPALButton gPalButton1 = (GPALButton)GPAL.Button
.Default
.WithName("button1")
.WithText("Exit")
.WithCallback(ExitButtonClickHandler)
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.E); // Alt-E
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPalButton1)
.ShowDialog();
}
private static void ExitButtonClickHandler(object sender, EventArgs e)
{
Control control = (Control)sender;
while (null != control.Parent)
control = control.Parent;
control.Hide();
}
Chart
Instantiates a new GPALChart for use on GPAL forms.
Callback EventHandler is invoked on the GPALChart.WindowsControl.Clicked event.
Declaration
public static IAllowControlSettingsAndChartSettings Chart { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettingsAndChartSettings | Fluent interface to create your control |
Examples
static GPALChart gPalChart = (GPALChart)GPAL.Chart
.WithPalette(ChartColorPalette.Bright)
.WithCallback(ChartHandler) // invoked when chart gets clicked
.WithName("Chart 1");
static void Main(string[] args)
{
GenerateBarSeries();
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPalChart)
.ShowDialog();
}
private static void GenerateBarSeries()
{
string[] seriesArray = { "Cat", "Dog", "Bird", "Monkey" };
int[] pointsArray = { 2, 1, 7, 5 };
gPalChart.Titles.Add("Animals");
// Add series
for (int i = 0; i < seriesArray.Length; i++)
{
Series series = gPalChart.Series.Add(seriesArray[i]);
// series.ChartType = SeriesChartType.Bar;
series.Points.Add(pointsArray[i]);
Legend legend = new Legend(seriesArray[i]);
// legend.Alignment = StringAlignment.Near;
gPalChart.Legends.Add(legend);
}
}
Checkbox
Instantiates a new GPALCheckbox for use on a GPAL form.
Callback EventHandler is invoked on the GPALCheckbox.WindowsControl.CheckChanged event.
Default is not checked
Declaration
public static IAllowControlSettingsEnabledAndChecked Checkbox { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettingsEnabledAndChecked | Fluent interface to create your control |
Examples
static GPALCheckbox gPALCheckbox1 = (GPALCheckbox)GPAL.Checkbox
.WithChecked(true)
.WithText("Overwrite File")
.WithCallback(CheckboxHandler); // on check changed event handler
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPALCheckbox1)
.ShowDialog();
}
private static void CheckboxHandler(object sender, EventArgs e)
{
if (((CheckBox) sender).Checked)
{
gPALCheckbox2.Checked = false; // uncheck the other, to act like a radio button
}
}
Converter
New GPAL Convertor
Declaration
public static IAllowConverterInput Converter { get; }
Property Value
| Type | Description |
|---|---|
| IAllowConverterInput |
Database
Instantiates a new fluent Database SETTINGS object.
This data object defines settings for use by .FillInFrom method.
Declaration
public static IAllowDatabaseSettings Database { get; }
Property Value
| Type | Description |
|---|---|
| IAllowDatabaseSettings | Fluent interface to define your database input |
Examples
// retrieve the top 4 rows from table TestInput from GPAL database on server "SQLSERVER\DATABASE"
Database inputDatabase = (Database)GPAL.Database
.WithServerName(@"SQLSERVER\DATABASE")
.WithDatabaseName("GPAL")
.WithTableName("TestInput")
.WithRowCount(4);
Browser myBrowser = (Browser)GPAL.Browser
.WithBrowserType(BrowserType.Edge)
.WithDriverLocation(@"c:\drivers")
.GoTo("https://www.ebay.com/")
.WithWaitOnDocumentReady(true)
.WithSelector(searchSelector)
.CallAfterFillIn(CallAFterFillIn) // after each row is consumed, invoke CallAfterFillIn
.FillInFrom(inputDatabase); // after each row is consumed, invoke CallAfterFillIn
File
Instantiates a new fluent File SETTINGS object.
This data object defines settings for use by the .FillInFrom method.
Declaration
public static IAllowFileName File { get; }
Property Value
| Type | Description |
|---|---|
| IAllowFileName | Fluent interface to define your file input |
Examples
File inputFile = (File)GPAL.File
.WithFileName(@"c:\ebay.words.txt");
Browser myBrowser = (Browser)GPAL.Browser
.WithBrowserType(BrowserType.Edge)
.WithDriverLocation(@"c:\drivers")
.GoTo("https://www.ebay.com/")
.WithWaitOnDocumentReady(true)
.WithSelector(searchSelector)
.CallAfterFillIn(CallAFterFillIn) // after each row is consumed, invoke CallAfterFillIn
.FillInFrom(inputFile); // after each row is consumed, invoke CallAfterFillIn
Form
Instantiates a new GPALForm for creating simple interactive user interfaces.
Declaration
public static IAllowFormSettings Form { get; }
Property Value
| Type | Description |
|---|---|
| IAllowFormSettings | Fluent interface to create your GPAL GUI |
Examples
static GPALButton gPalButton1 = (GPALButton)GPAL.Button
.WithName("button1")
.WithText("Exit")
.WithCallback(ExitButtonClickHandler)
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.E); // Alt-E
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPalButton1)
.ShowDialog();
}
private static void ExitButtonClickHandler(object sender, EventArgs e)
{
Control control = (Control)sender;
while (null != control.Parent)
control = control.Parent;
control.Hide();
}
GPALSettings
Declaration
public static GPALSettings GPALSettings { get; }
Property Value
| Type | Description |
|---|---|
| GPALSettings |
Grid
Declaration
public static IAllowGridActions<string> Grid { get; }
Property Value
| Type | Description |
|---|---|
| IAllowGridActions<System.String> |
ImageHelper
Declaration
public static ImageHelper ImageHelper { get; }
Property Value
| Type | Description |
|---|---|
| ImageHelper |
Input
Instantiates a new one-line GPALInput control for use on a GPAL form.
Callback EventHandler is invoked on the GPALInput.WindowsControl.TextChanged event.
Declaration
public static IAllowControlSettingsPlaceholderEnabledAndPassword Input { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettingsPlaceholderEnabledAndPassword | Fluent interface to create your control |
Examples
static GPALInput gPalInput = (GPALInput)GPAL.Input
.WithText(@"c:\drivers")
.WithCallback(InputHandler); // on text changed event handler
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPalInput)
.ShowDialog();
}
KEYEVENTF_EXTENDEDKEY
The extended-key flag indicates whether the keystroke message originated from one of the additional keys on the enhanced keyboard. The extended keys consist of the ALT and CTRL keys on the right-hand side of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; the NUM LOCK key; the BREAK (CTRL+PAUSE) key; the PRINT SCRN key; and the divide (/) and ENTER keys in the numeric keypad. The extended-key flag is set if the key is a extended key For use with keybd_event
Declaration
public static uint KEYEVENTF_EXTENDEDKEY { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
Examples
keybd_event(GPAL.VK_CONTROL_LEFT, 0, GPAL.KEYEVENTF_EXTENDEDKEY | 0, 0);
KEYEVENTF_KEYUP
Indicates a keyup keystroke is being sent. For use with keybd_event
Declaration
public static uint KEYEVENTF_KEYUP { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
Examples
keybd_event(GPAL.VK_CONTROL_LEFT, 0, GPAL.KEYEVENTF_EXTENDEDKEY | GPAL.KEYEVENTF_KEYUP, 0);
Label
Instantiates a new GPALLabel for use on a GPAL form.
Callback EventHandler is invoked on the GPALLabel.WindowsControl.Clicked event.
Declaration
public static IAllowControlSettings Label { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettings | Fluent interface to create your control |
Examples
static GPALLabel gPalLabel = (GPALLabel)GPAL.Label
.WithText("Form Tester");
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPalLabel)
.ShowDialog();
}
Launcher
Declaration
public static IAllowExecutableSetup Launcher { get; }
Property Value
| Type | Description |
|---|---|
| IAllowExecutableSetup |
Logger
Declaration
public static IAllowLoggingSettings Logger { get; }
Property Value
| Type | Description |
|---|---|
| IAllowLoggingSettings |
LoggerList
Declaration
public static List<IGPALLogger> LoggerList { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<IGPALLogger> |
New GPAL Mail handler
Declaration
public static IAllowEmailServerSettings Mail { get; }
Property Value
| Type | Description |
|---|---|
| IAllowEmailServerSettings |
OttoMagicClient
OttoMagic RESTClient
Declaration
public static IRESTClient OttoMagicClient { get; }
Property Value
| Type | Description |
|---|---|
| IRESTClient |
OttoMagicRestApiBaseUrl
Declaration
public static string OttoMagicRestApiBaseUrl { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
RadioButton
Instantiates a new GPALRadioButton for use on a GPAL form.
Callback EventHandler is invoked on the GPALRadioButton.WindowsControl.CheckChanged event.
Default is not selected
Declaration
public static IAllowControlSettingsEnabledAndChecked RadioButton { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettingsEnabledAndChecked | Fluent interface to create your control |
Examples
static GPALRadioButton gPalRadioButton1 = (GPALRadioButton)GPAL.RadioButton
.WithChecked(true)
.WithName("Radiobutton1")
.WithText("Chrome")
.WithCallback(RadioButton1Handler); // on check changed event handler
static GPALRadioButton gPalRadioButton2 = (GPALRadioButton)GPAL.RadioButton
.WithName("Radiobutton2")
.WithText("Edge")
.WithCallback(RadioButton2Handler); // on check changed event handler
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPalRadioButton1)
.WithFormControl(gPalRadioButton2)
.ShowDialog();
}
private static void RadioButtonHandler(object sender, EventArgs e)
{
if (((CheckBox) sender).Checked)
{
// YOUR CODE HERE - you don't have to thave two handlers, you could have one
}
}
RESTClient
Instantiate a new fluent RESTClient
Declaration
public static IAllowRESTEndpoint RESTClient { get; }
Property Value
| Type | Description |
|---|---|
| IAllowRESTEndpoint |
Examples
RESTClient client = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithEndpoint(ApiEndpoint.QuerySelectors)
.WithName("ButtonClient")
.WithParameters(new { selector = ".button" })
.WithHttpMethod("POST")
.ToGPALObject();
var elements = client.Execute<List<GPALElement>>(); // Logs "[ButtonClient][...]" if error
// Reuse
var moreElements = client
.WithParameters(new { selector = ".link" })
.Execute<List<GPALElement>>();
RESTClient client2 = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithName("TestClient")
.ToGPALObject();
client2.WithText("abc")
.InputText("//input")
.Execute(); // POST /input-text with { "text": "abc", "xpath": "//input" }
RESTClient client3 = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithName("TestClient")
.ToGPALObject();
// EXAMPLES - not working code
// QuerySelector (CSS only)
var singleCss = client3.QuerySelector(".header")
.Execute<GPALElement>(); // GET /query-selector with { "css": ".header" }
// QuerySelectors (CSS only)
var allCss = client3.QuerySelectors(".sidebar-item")
.Execute<List<GPALElement>>(); // GET /query-selectors with { "css": ".sidebar-item" }
// Evaluate (XPath only)
var singleXPath = client3.Evaluate("//div[1]")
.Execute<GPALElement>(); // GET /evaluate with { "xpath": "//div[1]" }
// EvaluateAll (XPath only)
var allXPath = client3.EvaluateAll("//p")
.Execute<List<GPALElement>>(); // GET /evaluate-all with { "xpath": "//p" }
// Chaining with built-in methods, reusing results with names
RESTClient client4 = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithName("BuiltInChainClient")
.WithEndpoint(ApiEndpoint.Evaluate)
.WithXPath("//div[@class='product-name']")
.WithResultName("productName")
.ExecuteAndChain<string>() // Result 0: "Laptop"
.WithEndpoint(ApiEndpoint.InputText)
.WithXPath("//input[@id='search']")
.WithTextFromResult("productName") // Use Result "productName": "Laptop"
.WithResultName("inputResult")
.ExecuteAndChain() // Submits "Laptop" to the input field
.WithEndpoint(ApiEndpoint.GetCurrentUrl)
.WithResultName("currentUrl")
.ExecuteAndChain<string>() // Result 1: "http://localhost:3000/search?q=Laptop"
.WithEndpoint(ApiEndpoint.Goto)
.WithUrlFromResult("currentUrl") // Use Result "currentUrl": "http://localhost:3000/search?q=Laptop"
.ExecuteAndChain(); // Navigates to the URL
var results = client4.GetExecutionResults();
Console.WriteLine($"Product Name (Result 0): {results[0]}"); // "Laptop"
Console.WriteLine($"Current URL (Result 1): {results[1]}"); // "http://localhost:3000/search?q=Laptop"
// Chaining with JavaScript, reusing results with names
RESTClient client5 = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithName("ScriptClient")
.WithEndpoint(ApiEndpoint.ExecuteJavaScript)
.WithParameters("//div[@class='item']")
.WithScript("return Array.from(arguments[0]).map(el => el.id);") // Returns ["item1", "item2"]
.WithResultName("elementIds")
.ExecuteAndChain<List<string>>()
.WithEndpoint(ApiEndpoint.ExecuteJavaScript)
.WithParametersFromResult("elementIds") // Use Result "elementIds": ["item1", "item2"]
.WithScript("return arguments[0][1];") // Returns "item2"
.WithResultName("secondId")
.ExecuteAndChain<string>()
.WithEndpoint(ApiEndpoint.ExecuteJavaScript)
.WithParametersFromResult("elementIds") // Use Result "elementIds": ["item1", "item2"]
.WithScript("return arguments[0].length;") // Returns 2
.WithResultName("idCount")
.ExecuteAndChain<int>();
var results2 = client5.GetExecutionResults();
Console.WriteLine($"Element IDs (Result 0): {string.Join(", ", (List<string>)results2[0])}"); // "item1, item2"
Console.WriteLine($"Second ID (Result 1): {results2[1]}"); // "item2"
Console.WriteLine($"Count of IDs (Result 2): {results2[2]}"); // 2
// Mixing named and ordinal lookups
RESTClient client6 = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithName("MixedLookupClient")
.WithEndpoint(ApiEndpoint.Evaluate)
.WithXPath("//div[@class='product-name']")
.WithResultName("productName")
.ExecuteAndChain<string>() // Result 0: "Laptop"
.WithEndpoint(ApiEndpoint.ExecuteJavaScript)
.WithParametersFromResult("productName") // Use Result "productName": "Laptop"
.WithScript("return 'Search term: ' + arguments[0];") // Returns "Search term: Laptop"
.ExecuteAndChain<string>() // Result 1 (unnamed)
.WithEndpoint(ApiEndpoint.InputText)
.WithXPath("//input[@id='search']")
.WithTextFromResult(1) // Use Result 1 (ordinal): "Search term: Laptop"
.ExecuteAndChain(); // Submits "Search term: Laptop" to the input field
var results3 = client6.GetExecutionResults();
Console.WriteLine($"Product Name (Result 0): {results3[0]}"); // "Laptop"
Console.WriteLine($"Script Result (Result 1): {results3[1]}"); // "Search term: Laptop"
// Using Execute (non-chaining) and reusing results later
RESTClient client7 = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithName("NonChainingClient")
.WithEndpoint(ApiEndpoint.Evaluate)
.WithXPath("//div[@class='product-name']")
.WithResultName("productName");
var product = client7.Execute<string>(); // Result 0: "Laptop", stored in _executionResults
client7.WithEndpoint(ApiEndpoint.InputText)
.WithXPath("//input[@id='search']")
.WithTextFromResult("productName") // Use Result "productName": "Laptop"
.WithResultName("inputResult")
.Execute(); // Submits "Laptop" to the input field
var results4 = client7.GetExecutionResults();
Console.WriteLine($"Product Name (Result 0): {results4[0]}"); // "Laptop"
// Can also use your own endpoint names (string)
RESTClient client = GPAL.RESTClient
.WithAPIBase(GPAL.OttoMagicRestApiBaseUrl)
.WithName("BuiltInChainClient")
.WithEndpoint("evaluate")
.WithXPath("//div[@class='product-name']")
.WithResultName("productName")
.ExecuteAndChain<string>() // Result 0: "Laptop"
.WithEndpoint("input-text")
.WithXPath("//input[@id='search']")
.WithTextFromResult("productName") // Use Result "productName": "Laptop"
.WithResultName("inputResult")
.ExecuteAndChain() // Submits "Laptop" to the input field
.WithEndpoint("get-current-url")
.WithResultName("currentUrl")
.ExecuteAndChain<string>() // Result 1: "http://localhost:3000/search?q=Laptop"
.WithEndpoint("goto")
.WithUrlFromResult("currentUrl") // Use Result "currentUrl": "http://localhost:3000/search?q=Laptop"
.ExecuteAndChain(); // Navigates to the URL
var results = client.GetExecutionResults();
Console.WriteLine($"Product Name (Result 0): {results[0]}"); // "Laptop"
Console.WriteLine($"Current URL (Result 1): {results[1]}"); // "http://localhost:3000/search?q=Laptop"
Selector
Instantiates a new fluent GPAL Selector object used to locate an element.
Selectors are for browsers or applications.
Declaration
public static IAllowSelectorSettings Selector { get; }
Property Value
| Type | Description |
|---|---|
| IAllowSelectorSettings | Fluent interface to create your workflow |
Examples
// Sample Application selector for the current tab writing surface in Notepad++
Selector notepadPane = (Selector)GPAL.Selector
.WithName("Notepad Pane")
.WithXPath("/Window/Pane[1]")
.WithOffsetX(10)
.WithOffsetY(10);
// Sample Browser selector, selector paths are evaluated in order they are declared.
// If at least one eleement is found for the selector path, then no other paths are evaluated.
// This shows two paths, first CSS then XPath.
Selector searchSelector = (Selector)GPAL.Selector
.WithName("SearchInput")
.WithCSS("#gh-ac")
.WithXPath("//*[@id=\"gh-ac\"]")
.MatchPlaceholder("Search for anything"); // must match this to be found
Tab
Instantiates a new GPALTab for use on a GPAL form.
Callback EventHandler is invoked on the GPALTab.WindowsControl.Clicked event.
Declaration
public static IAllowControlSettings Tab { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettings | Fluent interface to create your control |
Examples
static GPALTab gPalTab1 = (GPALTab)GPAL.Tab
.WithName("Tab1")
.WithText("Tab 1")
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.D1); // Alt-1
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithTab(gPalTab1) // items after this are placed on this tab
.WithFormControl(gPalRadioButton1)
.WithFormControl(gPalRadioButton2)
.ShowDialog();
}
TextArea
Instantiates a new GPALTextArea for use on a GPAL form.
Callback EventHandler is invoked on the GPALTextarea.WindowsControl.TextChanged event.
Declaration
public static IAllowControlSettingsAndEnabled TextArea { get; }
Property Value
| Type | Description |
|---|---|
| IAllowControlSettingsAndEnabled | Fluent interface to create your control |
Examples
static GPALTextArea gPalTextArea = (GPALTextArea)GPAL.TextArea
.WithText("Type something here")
.WithCallback(TextAreaHandler) // on text changed event handler
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.T); // Alt-T
static void Main(string[] args)
{
Form myForm = (Form)GPAL.Form
.WithTitle("Simple Form Test")
.WithFormControl(gPalTextArea)
.ShowDialog();
}
Version
Declaration
public static string Version { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
VK_ALT
Alt key virtual keycode (VK) for use with keybd_event. https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
Declaration
public static byte VK_ALT { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_BACK
Backspace key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_BACK { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_CONTROL_LEFT
Left Control key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_CONTROL_LEFT { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_CONTROL_RIGHT
Right Control key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_CONTROL_RIGHT { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_DELETE
Delete key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_DELETE { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_DOWN
Down Arrow key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_DOWN { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_END
End key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_END { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_F10
F10 key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_F10 { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_HOME
Home key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_HOME { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_NEXT
Page Down key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_NEXT { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_PRIOR
Page Up key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_PRIOR { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_RETURN
Enter/Return key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_RETURN { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_SHIFT_LEFT
Left Shift key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_SHIFT_LEFT { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_SHIFT_RIGHT
Right Shift key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_SHIFT_RIGHT { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_SPACE
Space bar key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_SPACE { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
VK_TAB
Tab key virtual keycode (VK) for use with keybd_event
Declaration
public static byte VK_TAB { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
Methods
AppCallIfFound(Application.CallIfDelegate)
Global Browser CallIfFound handler called for every selector in every Unit of Work
Declaration
public static IAllowGPALSettings AppCallIfFound(Application.CallIfDelegate callIfFound)
Parameters
| Type | Name | Description |
|---|---|---|
| Application.CallIfDelegate | callIfFound |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
AppCallIfNotFound(Application.CallIfDelegate)
Global Browser CallIfNotFound handler called for every selector in every Unit of Work
Declaration
public static IAllowGPALSettings AppCallIfNotFound(Application.CallIfDelegate callIfNotFound)
Parameters
| Type | Name | Description |
|---|---|---|
| Application.CallIfDelegate | callIfNotFound |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
BrowserGet(String)
Declaration
public static IBrowser BrowserGet(string url)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url |
Returns
| Type | Description |
|---|---|
| IBrowser |
BrowserGoto(String)
Declaration
public static IBrowser BrowserGoto(string url)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url |
Returns
| Type | Description |
|---|---|
| IBrowser |
CallIfFound(Browser.CallIfDelegate)
Global Browser CallIfFound handler called for every selector in every Unit of Work
Declaration
public static IAllowGPALSettings CallIfFound(Browser.CallIfDelegate callIfFound)
Parameters
| Type | Name | Description |
|---|---|---|
| Browser.CallIfDelegate | callIfFound |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
CallIfNotFound(Browser.CallIfDelegate)
Global Browser CallIfNotFound handler called for every selector in every Unit of Work
Declaration
public static IAllowGPALSettings CallIfNotFound(Browser.CallIfDelegate callIfNotFound)
Parameters
| Type | Name | Description |
|---|---|---|
| Browser.CallIfDelegate | callIfNotFound |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
CaptureScreen(Browser)
Take a screenshot
Declaration
public static IAllowGraphicSettings CaptureScreen(Browser browser)
Parameters
| Type | Name | Description |
|---|---|---|
| Browser | browser |
Returns
| Type | Description |
|---|---|
| IAllowGraphicSettings | Bitmap of the screen |
Examples
Bitmap screenshot = GPAL.CaptureScreen();
CssSelector(String)
Helper for shorthand notation
Declaration
public static Selector CssSelector(string css)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | css |
Returns
| Type | Description |
|---|---|
| Selector |
ElementAssistant(Application)
Instantiates a new Application ElementAssistant with fluent methods to help you manipulate AutomationElements in callback EventHandlers.
Declaration
public static IAllowForSelector ElementAssistant(Application application)
Parameters
| Type | Name | Description |
|---|---|---|
| Application | application | Application object associated with the elements/callback |
Returns
| Type | Description |
|---|---|
| IAllowForSelector | Fluent AutomationElement assistant to use in callback EventHandler |
Examples
// CallIfFound handler
public static int FoundNotepadPane(Application application, List<GPALAutomationElement> foundElements, List<GPALAutomationElement> matchedElements, Selector selector)
{
ElementAssistant elementAssistant = (ElementAssistant) GPAL.ElementAssistant(application);
foreach (GPALAutomationElement element in foundElements)
{
elementAssistant
.ForSelector(selector) // for interaction type, offsetX and offsetY
.WithElement(element)
.WithHardware // can override the selector interaction type here for this one element
.LeftClick();
}
return 0;
}
ElementAssistant(Selector)
Instantiates a new Browser ElementAssistant object with fluent methods to help you manipulate WebElements in Callback EventHandlers.
Declaration
public static IAllowElementSetting ElementAssistant(Selector selector)
Parameters
| Type | Name | Description |
|---|---|---|
| Selector | selector |
Returns
| Type | Description |
|---|---|
| IAllowElementSetting | Fluent GPALElement assistant to use in callback EventHandler |
Examples
public static int CallIfFound(Browser browser, List<GPALElement> foundElements, List<GPALElement> matchedElements, Selector selector)
{
elementAssistant = (ElementAssistant) GPAL.ElementAssistant(browser);
foreach (GPALElement webElement in matchedElements)
{
elementAssistant
.ForSelector(selector) // for interaction type, offsetX and offsetY
.WithElement(webElement)
.WithJavscript // can override the selector interaction type here for this one element
.LeftClick();
}
}
FileFor(String)
Declaration
public static IGPALFile FileFor(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path |
Returns
| Type | Description |
|---|---|
| IGPALFile |
GridForType<T>()
Declaration
public static IGPALGrid<T> GridForType<T>()
Returns
| Type | Description |
|---|---|
| IGPALGrid<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
LoadSettings(IGPALFile)
Declaration
public static void LoadSettings(IGPALFile settingsFile = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IGPALFile | settingsFile |
MyMethodName()
Returns the calling methods name (used in Information/Exception messages).
Instead of harcoding method names, call MyMethodName.
Declaration
public static string MyMethodName()
Returns
| Type | Description |
|---|---|
| System.String | Calling method's name |
Examples
Message = $"{GPAL.MyMethodName()}: Exception: Unable to load image. {ex.Message}"
PublishSimpleEvent(Enums.GPALEventType, String, Object, Enums.GPALObjectType, Exception)
Publish a message to either the information channel or exception channel (if exception passed in) Publish will insert the calling methods name, so there is no need to call GPAL.MyMethodName() A screenshot is published as well as the Browser/Application object to do what you want with in your handler
Declaration
public static void PublishSimpleEvent(Enums.GPALEventType gPALEventType, string msg, dynamic gPALObject, Enums.GPALObjectType gPALObjectType, Exception ex = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Enums.GPALEventType | gPALEventType | |
| System.String | msg | Message to publish |
| System.Object | gPALObject | GPAL object [Application, Browser, GPALForm, UnitOfWork] |
| Enums.GPALObjectType | gPALObjectType | The type of GPAL object passed in |
| System.Exception | ex | [Optional]Exception raised |
Examples
GPAL.PublishSimpleEvent("An Information Channel Message.", application, GPALObjectType.Application);
GPAL.PublishSimpleEvent("An Exception Channel Message.", browser, GPALObjectType.Browser, exception);
SaveSettings(IGPALFile)
Declaration
public static void SaveSettings(IGPALFile settingsFile = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IGPALFile | settingsFile |
WithAutoUpdateWebDriver(Boolean)
Automatically download and unzip the web driver that matches the version of the browser being run. This uses setting which will be in the GPAL.yaml configuration file which is loaded on startup (or loaded on-demand with a path).
Declaration
public static IAllowGPALSettings WithAutoUpdateWebDriver(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse | Auto Update? [true] |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings |
WithDefaultErrorPlaceholder(String)
When GPAL is unable to retrieve data from an element, this message will be placed in the grid.
GPAL will always strive to give you as much data as possible until you get your selectors perfected.
Declaration
public static IAllowGPALSettings WithDefaultErrorPlaceholder(string message = "##UNABLE TO GET##")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | message | The message to substitute for no data. |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
WithDriverLocation(String)
The location of the browser drivers to be used for each GPAL.Browser instance.
This can be overridden at the GPAL.Browser level, as well.
Additionally, if not defined, the default location is the same directory as the GPAL executable.
Declaration
public static IAllowGPALSettings WithDriverLocation(string driverPath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | driverPath | Path to the drivers folder |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
WithExceptionHandler(EventHandler<GPAL.GPALEventArgs>)
Set the handler to receive handled Exception messages from GPAL.
GPAL also sets an unhandled exception handler and will publish unhandled exceptions to this channel as well.
GPAL will terminate on unhandled exceptions after publishing to the channel.
Declaration
public static IAllowGPALSettings WithExceptionHandler(EventHandler<GPAL.GPALEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventHandler<GPAL.GPALEventArgs> | eventHandler | Your Exception channel event handler |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
Examples
GPAL.WithExceptionHandler(ExceptionEventHandler)
.WithInformationHandler(InformationEventHandler)
.WithTypingDelay(50);
WithImageMatchingPercentage(Int32)
Sets the image matching percentage for image Selectors.
Declaration
public static IAllowGPALSettings WithImageMatchingPercentage(int matchPercent)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | matchPercent | Image matching percentage [default is 80 (80%)] |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to allow more GPAL settings |
Examples
GPAL.WithTypingDelay(50)
.WithImageMatchingPercentage(80)
.WithSimulateMouse(true);
WithInformationHandler(EventHandler<GPAL.GPALEventArgs>)
Set the handler to receive Information messages from GPAL which you might like to know about.
Declaration
public static IAllowGPALSettings WithInformationHandler(EventHandler<GPAL.GPALEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventHandler<GPAL.GPALEventArgs> | eventHandler | Your Information channel event handler |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
Examples
GPAL.WithExceptionHandler(ExceptionEventHandler)
.WithInformationHandler(InformationEventHandler)
.WithTypingDelay(50);
WithNoFallbackActions(Boolean)
Declaration
public static IAllowGPALSettings WithNoFallbackActions(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings |
WithPromptBeforeUnexpectedExit(Boolean)
Prompt 'Press any key...' before terminating due to an uncaught exception. GPAL tries to handle all exceptions and continue running, publishing events with more information.
Declaration
public static IAllowGPALSettings WithPromptBeforeUnexpectedExit(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse | true - prompt before exit |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
WithPublishStackTrace(Boolean)
Print the stack trace along with the published GPAL message
Declaration
public static IAllowGPALSettings WithPublishStackTrace(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings |
WithPublishToConsole(Boolean)
Print the published information or exception messages to the console.
Declaration
public static IAllowGPALSettings WithPublishToConsole(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
WithPublishToDatabase(GPALDatabase)
Print the published information or exception messages to the supplied database. Uses Database Create sql One column for each property in GPALEventArgs
Declaration
public static IAllowGPALSettings WithPublishToDatabase(GPALDatabase database)
Parameters
| Type | Name | Description |
|---|---|---|
| GPALDatabase | database |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
WithPublishToDebug(Boolean)
Print the published information or exception messages to the output window in visual studio.
Declaration
public static IAllowGPALSettings WithPublishToDebug(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to specify more global settings |
WithSeleniumToppingBrowser(Boolean)
Top the browser window with Selenium.
For Firefox, GPAL will always top the browser via a mouse click. FF will not top via Selenium nor javascript.
Topping the browser window ensures it is in focus for the next action.
Declaration
public static IAllowGPALSettings WithSeleniumToppingBrowser(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to allow more GPAL settings |
Examples
GPAL.WithTypingDelay(50)
.WithSeleniumToppingBrowse(true)
.WithSimulateMouse(true)
WithSimulateMouse(Boolean)
Global setting to simulate a human moving the mouse to the next point for all commands.
Default is false
Declaration
public static IAllowGPALSettings WithSimulateMouse(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to allow more GPAL settings |
Examples
GPAL.WithTypingDelay(50)
.WithImageMatchingPercentage(80)
.WithSimulateMouse(true)
WithStopOnNotFound(Boolean)
Global setting instructing GPAL to terminate if any Selector cannot find any elements.
This is the GLOBAL setting affecting all Selectors.
This setting is also available on individual selectors to only stop on critical Selectors.
Default is false
Declaration
public static IAllowGPALSettings WithStopOnNotFound(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to allow more GPAL settings |
Examples
GPAL.WithTypingDelay(50)
.WithImageMatchingPercentage(80)
.WithStopOnNotFound(true)
WithTypingDelay(Int32)
Sets the inter-character typing delay when emulating keyboard typing.
Used with Selector .WithHardware interaction type.
Default is 100
Declaration
public static IAllowGPALSettings WithTypingDelay(int delayInTicks)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | delayInTicks | Inter-character delay in miliseconds |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings | Fluent interface to allow more GPAL settings |
Examples
GPAL.WithTypingDelay(50)
.WithImageMatchingPercentage(80)
.WithSimulateMouse(true);
WithUseHardware(Boolean)
Force hardware emulation for all browser automation actions Default is using Selenium
Declaration
public static IAllowGPALSettings WithUseHardware(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse | Use hardware? [true] |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings |
WithUseJavaScript(Boolean)
Force javascript injection for all browser automation actions Default is using Selenium
Declaration
public static IAllowGPALSettings WithUseJavaScript(bool trueFalse = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | trueFalse | Use javacscript? [true] |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings |
WithUseOttoMagic(String)
Use Ottomatic browser extnsion to control the browser. [Stealth]
Declaration
public static IAllowGPALSettings WithUseOttoMagic(string ottoMagicExtensionPath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | ottoMagicExtensionPath |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings |
WithWaitFor(Int32)
Global setting to wait for time in ticks for an element to show up. Applied to every element in every workflow. Override in a unit of work using this pattern .WithSelector(select0or) .WaitFor(waitForInTicks) .LeftClick() NOTE: shortcut actions like LeftClick{selector) will not waitfor and no syntax will make them wait except this global setting
Declaration
public static IAllowGPALSettings WithWaitFor(int waitForInTicks)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | waitForInTicks |
Returns
| Type | Description |
|---|---|
| IAllowGPALSettings |
XPathSelector(String)
Declaration
public static Selector XPathSelector(string xpath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | xpath |
Returns
| Type | Description |
|---|---|
| Selector |