GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GenerallyPositive.Browser.WorkflowScheduler Class Reference

Runs whole workflows at once, each one building and owning whatever it drives. Scheduling only: it starts workflows, limits how many are in flight, spaces their starts, and waits for them. It knows nothing about browsers, which is why one workflow can run Chrome on OttoMagic while the next runs Firefox on Selenium.

For several steps against one browser you already have, use Browser.WithWorkflow(Action<IBrowser>) and Browser.Run instead. More...

Inheritance diagram for GenerallyPositive.Browser.WorkflowScheduler:
GenerallyPositive.Browser.IAllowScheduledWorkflow GenerallyPositive.Browser.IAllowScheduledWorkflowExecution GenerallyPositive.Browser.IAllowScheduledWorkflow

Public Member Functions

IAllowScheduledWorkflowExecution WithMaxAtOnce (int howMany)
 How many workflows may be in flight at once. One, the default, runs them one after another. This is a throttle rather than a mode: a site that objects to four browsers at once is the reason it exists.
IAllowScheduledWorkflowExecution WithStaggerStart (int delayInMs)
 The least time between two workflows starting. Workflows that build a browser spend their first seconds asking the machine for a port and starting a process, and a dozen doing that in the same instant is a dozen asking the same question before any of them has answered it. A quarter second apart, the default, costs nothing worth counting and leaves each one starting into a settled machine. Zero starts them all together, which is what to use when the workflows drive nothing external.
IAllowScheduledWorkflowExecution WithTimeout (int timeoutInMs)
 How long to wait for all the workflows before giving up on them. Without one, Run waits forever, and a workflow that never returns is a caller that never returns: a form that called Run on the thread it paints with stops painting and there is nothing left to press.

Giving up is not stopping. A workflow takes nothing to say it should quit, so an abandoned one keeps running on its thread with its browser open. What this buys is Run coming back and saying which ones were still going, which turns a frozen application into a report and a stack you can read.
IAllowScheduledWorkflowExecution WithWorkflow (Action workflow)
 Adds a workflow to be run. It takes nothing and is handed nothing: whatever it drives, it builds, and whatever it builds, it closes.
IAllowScheduledWorkflowExecution Run ()
 Runs every workflow added and returns once they have all finished. One that throws is reported and the rest carry on, because a site that was down is no reason to lose the other nine.
IAllowScheduledWorkflowExecution Run (out List< WorkflowRun > runs)
 Runs every workflow added and hands back what happened to each: whether it finished, how long it took, and what it threw if it threw. A run that publishes an event says so once; this says it in something a workflow can act on afterwards, such as mailing the three that failed.

Detailed Description

Runs whole workflows at once, each one building and owning whatever it drives. Scheduling only: it starts workflows, limits how many are in flight, spaces their starts, and waits for them. It knows nothing about browsers, which is why one workflow can run Chrome on OttoMagic while the next runs Firefox on Selenium.

For several steps against one browser you already have, use Browser.WithWorkflow(Action<IBrowser>) and Browser.Run instead.

.WithWorkflow(() =>
{
.WithBrowserType(BrowserType.Chrome)
.WithAutomationEngine(AutomationEngine.OttoMagic)
.GoTo("https://www.ebay.com")
.ToGPALObject();
b.WithSelector(GPAL.CssSelector("#gh-ac")).FillInFrom("laptop").SendKey(GPAL.VK_ENTER);
b.Close(true);
})
.WithWorkflow(() =>
{
// a different browser and a different engine, because nothing is copied from anywhere
.WithBrowserType(BrowserType.FireFox)
.WithAutomationEngine(AutomationEngine.Selenium)
.GoTo("https://www.walmart.com")
.ToGPALObject();
b.Close(true);
})
.Run(out List<WorkflowRun> runs); // two at a time, and what became of each
IAllowScheduledWorkflowExecution WithWorkflow(Action workflow)
Adds a workflow to be run. It takes nothing and is handed nothing: whatever it drives,...
IAllowScheduledWorkflowExecution WithMaxAtOnce(int howMany)
How many workflows may be in flight at once. One, the default, runs them one after another....
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
Definition GPAL.cs:49
static Selector CssSelector(string css, string selectorName=null)
Helper for shorthand notation.
Definition GPAL.cs:1026
static Browser.IAllowScheduledWorkflow Workflow
Runs whole workflows at once, each building and owning whatever it drives, so one can run Chrome on O...
Definition GPAL.cs:2122
static IAllowBrowserTypeOrGoto Browser
Instantiates a new fluent Browser object.
Definition GPAL.cs:617

Definition at line 80 of file WorkflowScheduler.cs.

Member Function Documentation

◆ Run() [1/2]

IAllowScheduledWorkflowExecution GenerallyPositive.Browser.WorkflowScheduler.Run ( )

Runs every workflow added and returns once they have all finished. One that throws is reported and the rest carry on, because a site that was down is no reason to lose the other nine.

Returns
Fluent interface to add more workflows or run them again.

Implements GenerallyPositive.Browser.IAllowScheduledWorkflowExecution.

Definition at line 171 of file WorkflowScheduler.cs.

◆ Run() [2/2]

IAllowScheduledWorkflowExecution GenerallyPositive.Browser.WorkflowScheduler.Run ( out List< WorkflowRun > runs)

Runs every workflow added and hands back what happened to each: whether it finished, how long it took, and what it threw if it threw. A run that publishes an event says so once; this says it in something a workflow can act on afterwards, such as mailing the three that failed.

Parameters
runsReceives one entry per workflow, in the order they were added.
Returns
Fluent interface to add more workflows or run them again.

Implements GenerallyPositive.Browser.IAllowScheduledWorkflowExecution.

Definition at line 183 of file WorkflowScheduler.cs.

◆ WithMaxAtOnce()

IAllowScheduledWorkflowExecution GenerallyPositive.Browser.WorkflowScheduler.WithMaxAtOnce ( int howMany)

How many workflows may be in flight at once. One, the default, runs them one after another. This is a throttle rather than a mode: a site that objects to four browsers at once is the reason it exists.

Parameters
howManyThe most workflows to have running at any moment.
Returns
Fluent interface to add more workflows or run them.

Implements GenerallyPositive.Browser.IAllowScheduledWorkflowExecution.

Definition at line 97 of file WorkflowScheduler.cs.

◆ WithStaggerStart()

IAllowScheduledWorkflowExecution GenerallyPositive.Browser.WorkflowScheduler.WithStaggerStart ( int delayInMs)

The least time between two workflows starting. Workflows that build a browser spend their first seconds asking the machine for a port and starting a process, and a dozen doing that in the same instant is a dozen asking the same question before any of them has answered it. A quarter second apart, the default, costs nothing worth counting and leaves each one starting into a settled machine. Zero starts them all together, which is what to use when the workflows drive nothing external.

Parameters
delayInMsThe least time between two workflows starting.
Returns
Fluent interface to add more workflows or run them.

Implements GenerallyPositive.Browser.IAllowScheduledWorkflowExecution.

Definition at line 119 of file WorkflowScheduler.cs.

◆ WithTimeout()

IAllowScheduledWorkflowExecution GenerallyPositive.Browser.WorkflowScheduler.WithTimeout ( int timeoutInMs)

How long to wait for all the workflows before giving up on them. Without one, Run waits forever, and a workflow that never returns is a caller that never returns: a form that called Run on the thread it paints with stops painting and there is nothing left to press.

Giving up is not stopping. A workflow takes nothing to say it should quit, so an abandoned one keeps running on its thread with its browser open. What this buys is Run coming back and saying which ones were still going, which turns a frozen application into a report and a stack you can read.

Parameters
timeoutInMsHow long to wait for them all. Zero or less waits forever, which is the default.
Returns
Fluent interface to add more workflows or run them.

Implements GenerallyPositive.Browser.IAllowScheduledWorkflowExecution.

Definition at line 143 of file WorkflowScheduler.cs.

◆ WithWorkflow()

IAllowScheduledWorkflowExecution GenerallyPositive.Browser.WorkflowScheduler.WithWorkflow ( Action workflow)

Adds a workflow to be run. It takes nothing and is handed nothing: whatever it drives, it builds, and whatever it builds, it closes.

Parameters
workflowThe workflow to run.
Returns
Fluent interface to add more workflows or run them.

Implements GenerallyPositive.Browser.IAllowScheduledWorkflow.

Definition at line 156 of file WorkflowScheduler.cs.


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