SetBatchId method

Class: BatchClose Platform: Selenium 3 Language: C# SDK:

Set the batch ID of the batches that should be closed.

Introduction

When closing a batch manually, this call is typically followed by a call to the method BatchClose.Close.

Syntax

EnabledBatchClose value = obj.SetBatchId(batchIds);

Parameters

batchIds
Type: string[]

One or more batches to be closed.

batchIds
Type: IEnumerable<string>

One or more batches to be closed.

Return value

Type: EnabledBatchClose
The returned object is an instance of a class inherited from BatchClose. This is to ensure that you only call BatchClose.Close if you've set the batch ID by calling SetBatchId

Example

The example below:

Note that the batch ID of the batch being closed needs to be passed to the BatchClose.SetBatchId method. In this example, we assume that a batch ID was set for all of the batches by assigning a unique ID to the APPLITOOLS_BATCH_ID environment variable. This is used as a default by the Configuration.SetBatch method which is set up in the suite Configuration object and then assigned to each Eyes instance.

 
/*
 * After creating the runner, configure it so that won't close the batch
 */
runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(10));
runner.DontCloseBatches = true;
/*
 * Setup a common batch for all tests
 */
BatchInfo batchInfo = new BatchInfo(batchName);
batchInfo.Id = MyGetUniqueBatchID(); // User defined
suiteConfig = (Configuration) new Configuration() 
    .SetBatch(batchInfo)
    /* ... other configurations */; 
/* 
 * Assign the configuration to all newly created Eyes instances
 */
eyes = new Eyes(runner);
eyes.SetConfiguration(suiteConfig);
/*
 * After all the tests have completed, in all the runners
 */
List<String> batchIds = new List<string>() { Environment.GetEnvironmentVariable("APPLITOOLS_BATCH_ID") };
BatchClose batchClose = new BatchClose();
batchClose.SetBatchId(batchIds).Close();