Execute Method

Class

BaseState.

Action

Executes the base state on the machine as specified by the desktop.

Syntax

C#
TestObject = BaseState.Execute();
VB
TestObject = BaseState.Execute()
Variable Description
TestObject The object for which the locator should wait.

Example: Use the configuration file to set the base state for a web application

To use the base state that is stored in the configuration file config.silk4net to set the base state for a web application:

C#
var baseState = new BrowserBaseState();
baseState.Execute();
VB
Dim baseState = New BrowserBaseState()
baseState.Execute()

To additionally store the base state in a variable:

C#
var baseState = new BrowserBaseState();
var browserApplication = (BrowserApplication) baseState.Execute();
VB
Dim baseState = New BrowserBaseState()
Dim browserApplication As BrowserApplication = baseState.Execute()

Example: Specify the browser and the URL of a web application in the base state

You can use the following code to specify Internet Explorer as the browser on which a web application should be tested and www.borland.com as the URL of the web application:

C#
var baseState = new BrowserBaseState(BrowserType.InternetExplorer, "www.borland.com");
baseState.Execute();
VB
Dim baseState = New BrowserBaseState(BrowserType.InternetExplorer, "www.borland.com")
baseState.Execute()

To additionally store the base state in a variable:

C#
var baseState = new BrowserBaseState(BrowserType.InternetExplorer, "www.borland.com");
var browserApplication = (BrowserApplication) baseState.Execute();
VB
Dim baseState = New BrowserBaseState(BrowserType.InternetExplorer, "www.borland.com")
Dim browserApplication As BrowserApplication = baseState.Execute()

To specify a mobile browser on a mobile device, for example Safari on an iOS device, you can use the following code:

C#
var baseState = new BrowserBaseState(BrowserType.Safari, "www.borland.com");
baseState.MobileDeviceName = "My iPhone";
baseState.Execute();
VB
Dim baseState = New BrowserBaseState(BrowserType.Safari, "www.borland.com")
baseState.MobileDeviceName = "My iPhone"
baseState.Execute()

Example: Specify the path to the executable and a locator for the main window of the AUT

You can use the following code to specify C:/windows/system32/notepad.exe as the path to the executable of the AUT and //Window[@caption='*Notepad*'] as the locator for the main window of the AUT:

C#
var baseState = new BaseState("C:/windows/system32/notepad.exe", "//Window[@caption='*Notepad*']");
baseState.Execute();
VB
Dim baseState = New BaseState("C:/windows/system32/notepad.exe", "//Window[@caption='*Notepad*']")
baseState.Execute()

To additionally store the base state in a variable:

C#
var baseState = new BaseState("C:/windows/system32/notepad.exe", "//Window[@caption='*Notepad*']");
var mainWindow = (Window) baseState.Execute();
VB
Dim baseState = New BaseState("C:/windows/system32/notepad.exe", "//Window[@caption='*Notepad*']")
Dim mainWindow As Window = baseState.Execute()