You can edit the base state in a script to specify how Silk4NET starts an application under test (AUT) during replay. You can specify the executable location of the AUT, the working directory, the URL and the connection string for a web application, and so on. For example, if you want to execute tests on a production web site, which have already been executed on a staging web site, you can simply change the URL in the base state and the tests are executed against the new web site.
To edit the base state in a script:
' VB code ' Go to web page 'demo.borland.com/InsuranceWebExtJS' BrowserBaseState baseState = new BrowserBaseState() ' <-- Insert your changes here! baseState.Execute()
// C# code //Go to web page 'demo.borland.com/InsuranceWebExtJS' BrowserBaseState baseState = new BrowserBaseState(); // <-- Insert your changes here! baseState.Execute();
' VB code baseState.Executable=executable
// C# code baseState.Executable=executable;For example, to specify the Calculator, type the following:
' VB code baseState.Executable = "C:\\Windows\\SysWOW64\\calc.exe"
// C# code baseState.Executable = "C:\\Windows\\SysWOW64\\calc.exe";To specify Mozilla Firefox, type the following:
' VB code baseState.Executable = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"
// C# code baseState.Executable = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
' VB code baseState.CommandLineArguments = commandLineArguments
// C# code baseState.CommandLineArguments = commandLineArguments;For example, to start Mozilla Firefox with the profile myProfile, type the following:
' VB code baseState.CommandLineArguments = "-p myProfile"
// C# code baseState.CommandLineArguments = "-p myProfile";
' VB code baseState.WorkingDirectory = workingDirectory
// C# code baseState.WorkingDirectory = workingDirectory;
' VB code baseState.ExecutablePattern = executablePattern
// C# code baseState.ExecutablePattern = executablePattern;For example, if you want to specify an executable pattern for the Calculator, type:
' VB code baseState.ExecutablePattern = "*\\calc.exe"
// C# code baseState.ExecutablePattern = "*\\calc.exe";
' VB code baseState.CommandLinePattern = commandLinePattern
// C# code baseState.CommandLinePattern = commandLinePattern;For example, if the command line of the application ends with com.example.MyMainClass you might want to use *com.example.MyMainClass as the command line pattern:
' VB code baseState.CommandLinePattern = "*com.example.MyMainClass"
// C# code baseState.CommandLinePattern = "*com.example.MyMainClass";
' VB code baseState.BrowserType = BrowserType.GoogleChrome
// C# code baseState.BrowserType = BrowserType.GoogleChrome;
' VB code baseState.Url = url
// C# code baseState.Url = url;For example, type the following:
' VB code baseState.Url = "demo.borland.com/InsuranceWebExtJS/"
// C# code baseState.Url = "demo.borland.com/InsuranceWebExtJS/";
' VB code baseState.ViewportHeight = viewportHeight baseState.ViewportWidth = viewportWidth
// C# code baseState.ViewportHeight = viewportHeight; baseState.ViewportWidth = viewportWidth;
' VB code New MobileBaseState(connectionString)
// C# code new MobileBaseState(connectionString);For information on the connection string, see Connection String for a Remote Desktop Browser or Connection String for a Mobile Device.
' VB code baseState.ConnectionString = "moz:firefoxOptions= {\"prefs\": { \"browser.download.dir\":\"C:/Download/\"}};"
// C# code baseState.ConnectionString = "moz:firefoxOptions= {\"prefs\": { \"browser.download.dir\":\"C:/Download/\"}};";For additional information, see Setting Options and Capabilities for Web-Driver Based Browsers.