You can change your tested application’s parameters not only in the TestedApps editor, but also from tests.
Changing Desktop Application Parameters
Changing Java Application Parameters
Changing Java Web Start Application Parameters
Changing AIR Application Parameters
Changing Desktop Application Parameters
To access an application’s run mode parameters from tests, you can use one of the following objects:
In addition, the TestedApps.AppName.Params.ActiveParams
object provides access to the current run mode’s parameters.
For example, to specify a working folder and command-line arguments for an application that will run in the Simple mode, you can use the following code:
JavaScript, JScript
TestedApps.MyApp.Params.SimpleParams.CommandLineParameters = "/test";
TestedApps.MyApp.Params.SimpleParams.WorkFolder = "C:\\Test";
Python
TestedApps.MyApp.Params.SimpleParams.CommandLineParameters = "test.txt"
TestedApps.MyApp.Params.SimpleParams.WorkFolder = "C:\\Test"
VBScript
TestedApps.MyApp.Params.SimpleParams.CommandLineParameters = "/test"
TestedApps.MyApp.Params.SimpleParams.WorkFolder = "C:\Test"
DelphiScript
TestedApps.MyApp.Params.SimpleParams.CommandLineParameters := '/test';
TestedApps.MyApp.Params.SimpleParams.WorkFolder := 'C:\Test';
C++Script, C#Script
TestedApps["MyApp"]["Params"]["SimpleParams"]["CommandLineParameters"] = "/test";
TestedApps["MyApp"]["Params"]["SimpleParams"]["WorkFolder"] = "C:\\Test";
You can also change an application’s run mode from tests. For more information, see Getting and Setting Run Mode From Tests.
Changing Java Application Parameters
The way you access Java application parameters from tests depends on the Use special runtime object setting of the application in the TestedApps editor.
If it is enabled (default), you can get or set the application parameters by using the TestedApps.JavaAppName object. For example:
JavaScript, JScript
function TestJava()
{
var app = TestedApps.MyJavaApp;
app.JVMExecutable = "C:\\Program Files\\Java\\jre7\\bin\\javaw.exe";
app.JarFileName = "C:\\Program Files\\MyApp\\MyApp.jar";
app.RunAsJar = true;
app.Run();
}
Python
def TestJava():
app = TestedApps.MyJavaApp
app.JVMExecutable = "C:\\Program Files\\Java\\jre7\\bin\\javaw.exe"
app.JarFileName = "C:\\Program Files\\MyApp\\MyApp.jar"
app.RunAsJar = True
app.Run()
VBScript
Sub TestJava
Set app = TestedApps.MyJavaApp
app.JVMExecutable = "C:\Program Files\Java\jre7\bin\javaw.exe"
app.JarFileName = "C:\Program Files\MyApp\MyApp.jar"
app.RunAsJar = True
app.Run
End Sub
DelphiScript
procedure TestJava();
var app: OleVariant;
begin
app := TestedApps.MyJavaApp;
app.JVMExecutable := 'C:\Program Files\Java\jre7\bin\javaw.exe';
app.JarFileName := 'C:\Program Files\MyApp\MyApp.jar';
app.RunAsJar := true;
app.Run;
end;
C#Script
function TestJava()
{
var app = TestedApps["MyJavaApp"];
app["JVMExecutable"] = "C:\\Program Files\\Java\\jre7\\bin\\javaw.exe";
app["JarFileName"] = "C:\\Program Files\\MyApp\\MyApp.jar";
app["RunAsJar"] = true;
app["Run"]();
}
For more information on the available properties, see the JavaTestedApp object description.
If the Use special runtime object setting is disabled (which is not recommended for all tests, except for legacy ones), you can access Java application parameters via the TestedApps.JavaAppName.Params.JavaParams
property (the property is obsolete; it is supported for backward compatibility only). This is done as shown in the example above, but the syntax is longer. For example:
JavaScript, JScript
function Test()
{
var params = TestedApps.MyApp.Params.JavaParams;
params.JVMExecutable = "C:\\Program Files\\Java\\jre7\\bin\\javaw.exe";
params.JarFileName = "C:\\Program Files\\MyApp\\MyApp.jar";
params.RunAsJar = true;
TestedApps.MyApp.Run();
}
Python
def TestJava():
params = TestedApps.MyApp.Params.JavaParams
params.JVMExecutable = "C:\\Program Files\\Java\\jre7\\bin\\javaw.exe"
params.JarFileName = "C:\\Program Files\\MyApp\\MyApp.jar"
params.RunAsJar = True
TestedApps.MyApp.Run()
VBScript
Sub Test
Dim params
Set params = TestedApps.MyApp.Params.JavaParams
params.JVMExecutable = "C:\Program Files\Java\jre7\bin\javaw.exe"
params.JarFileName = "C:\Program Files\MyApp\MyApp.jar"
params.RunAsJar = True
TestedApps.MyApp.Run
End Sub
DelphiScript
procedure Test;
var params;
begin
params := TestedApps.MyApp.Params.JavaParams;
params.JVMExecutable := 'C:\Program Files\Java\jre7\bin\javaw.exe';
params.JarFileName := 'C:\Program Files\MyApp\MyApp.jar';
params.RunAsJar := true;
TestedApps.MyApp.Run;
end;
C++Script, C#Script
function Test()
{
var params = TestedApps["MyApp"]["Params"]["JavaParams"];
params["JVMExecutable"] = "C:\\Program Files\\Java\\jre7\\bin\\javaw.exe";
params["JarFileName"] = "C:\\Program Files\\MyApp\\MyApp.jar";
params["RunAsJar"] = true;
TestedApps["MyApp"]["Run"]();
}
Changing Java Web Start Application Parameters
You can access parameters of the needed Java Web Start application in the Tested Applications collection by using the TestedApps.JavaWebStartAppName object.
The sample code below demonstrates how to add a new Java Web Start application to the list of tested applications, set application properties and run the application.
JavaScript, JScript
function Test()
{
// Add a Java Web Start application to the project
var ind = TestedApps.AddJavaWebStartApp();
var app = TestedApps.Items(ind);
// Specify Web Start application's launch parameters
app.JWSLauncher= "C:\\Program Files\\Java\\jre1.8.0\\Bin\\javaws.exe";
app.Location = "https://docs.oracle.com/javase/tutorialJWS/samples/deployment/dynamictree_webstartJWSProject/dynamictree_webstart.jnlp";
// Launches the Web Start application
app.Run();
// Test the application
…
app.Close();
}
Python
def Test():
# Add a Java Web Start application to the project
ind = TestedApps.AddJavaWebStartApp();
app = TestedApps.Items(ind);
# Specify Web Start application's launch parameters
app.JVMExecutable = "C:\\Program Files\\Java\\jre1.8.0\\Bin\\javaws.exe";
app.Location = "https://docs.oracle.com/javase/tutorialJWS/samples/deployment/dynamictree_webstartJWSProject/dynamictree_webstart.jnlp"
# Launches the Web Start application
app.Run();
# Test the application
# ...
app.Close();
VBScript
Sub Test
' Add a Java Web Start application to the project
ind = TestedApps.AddJavaWebStartApp
Set app = TestedApps.Items(ind)
' Specify Web Start application's launch parameters
app.Launcher = "C:\Program Files\Java\jre1.8.0\Bin\javaws.exe"
app.Location = "https://docs.oracle.com/javase/tutorialJWS/samples/deployment/dynamictree_webstartJWSProject/dynamictree_webstart.jnlp"
' Launches the Web Start application
app.Run
' Test the application
…
app.Close
End Sub
DelphiScript
procedure Test();
var ind, app;
begin
// Add a Java Web Start application to the project
ind := TestedApps.AddJavaWebStartApp();
app := TestedApps.Items(ind);
// Specify Web Start application's launch parameters
app.JWSLauncher := 'C:\Program Files\Java\jre1.8.0\Bin\javaws.exe';
app.Location := 'https://docs.oracle.com/javase/tutorialJWS/samples/deployment/dynamictree_webstartJWSProject/dynamictree_webstart.jnlp';
// Launches the Web Start application
app.Run;
// Test the application
…
app.Close;
end;
C++Script, C#Script
function Test()
{
// Add a Java Web Start application to the project
var ind = TestedApps["AddJavaWebStartApp"]();
var app = TestedApps["Items"](ind);
// Specify Web Start application's launch parameters
app["JWSLauncher"] = "C:\\Program Files\\Java\\jre1.8.0\\Bin\\javaws.exe";
app["Location"] = "https://docs.oracle.com/javase/tutorialJWS/samples/deployment/dynamictree_webstartJWSProject/dynamictree_webstart.jnlp";
// Launches the Web Start application
app["Run"]();
// Test the application
…
app["Close"]();
}
Note: |
Support for Java Web Start has been removed from Java version 11. |
For more information on the available properties, see the JavaWebStartTestedApp object description.
Changing AIR Application Parameters
The way you access AIR application parameters from tests depends on the Use special runtime object setting of the application in the TestedApps editor.
If it is enabled (by default), you can get or set the application parameters directly via the TestedApps.AIRAppName object. For example:
JavaScript, JScript
function TestAIR()
{
var app = TestedApps.MyAIRApp;
app.IsExecutable = false;
app.DebuggerExecutable = "C:\\airsdk\\bin\\adl.exe";
app.DescriptorFileName = "C:\\myApp\\myApp-app.xml";
app.Run();
}
Python
def TestAIR():
app = TestedApps.MyAIRApp
app.IsExecutable = False
app.DebuggerExecutable = "C:\\airsdk\\bin\\adl.exe"
app.DescriptorFileName = "C:\\myApp\\myApp-app.xml"
app.Run()
VBScript
Sub TestAIR
Set app = TestedApps.MyAIRApp
app.IsExecutable = False
app.DebuggerExecutable = "C:\airsdk\bin\adl.exe"
app.DescriptorFileName = "C:\myApp\myApp-app.xml"
app.Run
End Sub
DelphiScript
procedure TestAIR();
var app : OleVariant;
begin
app := TestedApps.MyAIRApp;
app.IsExecutable := false;
app.DebuggerExecutable := 'C:\airsdk\bin\adl.exe';
app.DescriptorFileName := 'C:\myApp\myApp-app.xml';
app.Run;
end;
C#Script
function TestAIR()
{
var app = TestedApps["MyAIRApp"];
app["IsExecutable"] = false;
app["DebuggerExecutable"] = "C:\\airsdk\\bin\\adl.exe";
app["DescriptorFileName"] = "C:\\myApp\\myApp-app.xml";
app["Run"]();
}
For more information on the available properties, see the AIRTestedApp object description.
If the Use special runtime object setting is disabled (which is not recommended for all tests, except for legacy ones), you can access AIR application parameters via the TestedApps.AIRAppName.Params.AIRParams
property (the property is obsolete; it is supported for backward compatibility only). This is similar to the previous example, but the syntax is longer. For example:
JavaScript, JScript
function Test()
{
TestedApps.MyApp.Params.AIRParams.DebuggerExecutable = "C:\\airsdk\\bin\\adl.exe";
TestedApps.MyApp.Params.AIRParams.DescriptorFileName = "C:\\myApp\\myApp-app.xml";
TestedApps.MyApp.Run();
}
Python
def TestAIR():
TestedApps.MyApp.Params.AIRParams.DebuggerExecutable = "C:\\airsdk\\bin\\adl.exe"
TestedApps.MyApp.Params.AIRParams.DescriptorFileName = "C:\\myApp\\myApp-app.xml"
TestedApps.MyApp.Run()
VBScript
Sub Test
TestedApps.MyApp.Params.AIRParams.DebuggerExecutable = "C:\airsdk\bin\adl.exe"
TestedApps.MyApp.Params.AIRParams.DescriptorFileName = "C:\myApp\myApp-app.xml"
TestedApps.MyApp.Run
End Sub
DelphiScript
procedure Test;
begin
TestedApps.MyApp.Params.AIRParams.DebuggerExecutable := 'C:\airsdk\bin\adl.exe';
TestedApps.MyApp.Params.AIRParams.DescriptorFileName := 'C:\myApp\myApp-app.xml';
TestedApps.MyApp.Run;
end;
C++Script, C#Script
function Test()
{
TestedApps["MyApp"]["Params"]["AIRParams"]["DebuggerExecutable"] = "C:\\airsdk\\bin\\adl.exe";
TestedApps["MyApp"]["Params"]["AIRParams"]["DescriptorFileName"] = "C:\\myApp\\myApp-app.xml";
TestedApps["MyApp"]["Run"]();
}
Changing ClickOnce Application Parameters
The way you access ClickOnce application parameters from tests depends on the Use special runtime object setting of the application in the TestedApps editor.
If it is enabled (by default), you can get or set the application parameters directly via the TestedApps.AppName object. For example:
JavaScript, JScript
TestedApps.MyApp.StartupLink = "http://www.example.com/MyApp/MyApp.application";
TestedApps.MyApp.ProcessToWait = "MyApp.exe";
Python
TestedApps.MyApp.StartupLink = "http://www.example.com/MyApp/MyApp.application"
TestedApps.MyApp.ProcessToWait = "MyApp.exe"
VBScript
TestedApps.MyApp.StartupLink = "http://www.example.com/MyApp/MyApp.application"
TestedApps.MyApp.ProcessToWait = "MyApp.exe"
DelphiScript
TestedApps.MyApp.StartupLink := 'http://www.example.com/MyApp/MyApp.application';
TestedApps.MyApp.ProcessToWait := 'MyApp.exe';
C++Script, C#Script
TestedApps["MyApp"]["StartupLink"] = "http://www.example.com/MyApp/MyApp.application";
TestedApps["MyApp"]["ProcessToWait"] = "MyApp.exe";
For more information on the available properties, see the ClickOnceTestedApp object description.
If the Use special runtime object setting is disabled (which is not recommended for all tests, except for legacy ones), you can access ClickOnce application parameters via the TestedApps.AppName.Params.ClickOnceParams
property. This is similar to the previous example, but the syntax is longer. For example:
JavaScript, JScript
TestedApps.MyApp.Params.ClickOnceParams.StartupLink = "http://www.example.com/MyApp/MyApp.application";
TestedApps.MyApp.Params.ClickOnceParams.ProcessToWait = "MyApp.exe";
Python
TestedApps.MyApp.Params.ClickOnceParams.StartupLink = "http://www.example.com/MyApp/MyApp.application"
TestedApps.MyApp.Params.ClickOnceParams.ProcessToWait = "MyApp.exe"
VBScript
TestedApps.MyApp.Params.ClickOnceParams.StartupLink = "http://www.example.com/MyApp/MyApp.application"
TestedApps.MyApp.Params.ClickOnceParams.ProcessToWait = "MyApp.exe"
DelphiScript
TestedApps.MyApp.Params.ClickOnceParams.StartupLink := 'http://www.example.com/MyApp/MyApp.application';
TestedApps.MyApp.Params.ClickOnceParams.ProcessToWait := 'MyApp.exe';
C++Script, C#Script
TestedApps["MyApp"]["Params"]["ClickOnceParams"]["StartupLink"] = "http://www.example.com/MyApp/MyApp.application";
TestedApps["MyApp"]["Params"]["ClickOnceParams"]["ProcessToWait"] = "MyApp.exe";
Changing Windows Store Application Parameters
You can access parameters of a needed Windows Store application in the Tested Application collection by using the TestedApps.AppName
property.
The sample code below shows how to add a new Windows Store application to the list of tested applications, set the application properties, and run the application.
JavaScript, JScript
function TestWinStore()
{
var app = TestedApps.MyWinStoreApp;
app.ApplicationName = "mypack.myapp";
app.Run();
}
Python
def TestWinStore():
app = TestedApps.MyWinStoreApp
app.PackageName = "mypack.myapp"
app.Run()
VBScript
Sub TestWinStore
Set app = TestedApps.MyWinStoreApp
app.ApplicationName = "mypack.myapp"
app.Run
End Sub
DelphiScript
procedure TestWinStore();
var app: OleVariant;
begin
app := TestedApps.MyMyWinStoreApp;
app.ApplicationName := 'mypack.myapp';
app.Run;
end;
C#Script
function TestWinStore()
{
var app = TestedApps["MyWinStoreApp"];
app["ApplicationName"] = "mypack.myapp";
app["Run"]();
}
For more information on available properties, see the WinStoreTestedApp
object description.
See Also
About Tested Applications
Editing Web Application Parameters
Editing Mobile Application Parameters From Tests
Run Modes and Parameters
Getting and Setting Run Mode From Tests