After you create and debug your TestLeft tests on your local computer, you may want to run them on remote computers. You can connect to the TestLeft test engine running on a remote computer and command it to execute the needed test instructions.
To do this, you use the RemoteDriver
object that TestLeft includes:
-
In your tests, create a
RemoteDriver
object. When creating the object, specify a remote computer, where you will run tests, and a user, under whose account the test will run. -
Use the
RemoteDriver
object to specify user actions to be simulated over a tested application on the specified remote computer. You do it the same way you use theLocalDriver
object to simulate user actions on your local computer. -
Run your test. During the test run, the
RemoteDriver
object connects to the test engine running on the remote computer and sends test commands to it: -
The test engine on the remote computer performs the needed test actions and gets test results. The test results are stored in a temporary folder on a remote computer.
You can use the following methods to save the test results to a desired location on your local computer:
.NET:
RemoteDriver.Log.Save
Java:
RemoteDriver.getLog().save
Requirements
Important: The TestLeft service must be running on the remote computer when you run your tests. See Running TestLeft Tests on Remote Computers - Requirements.
Example
The code below shows how to create a RemoteDriver
object that will connect to a remote computer and command the test engine to simulate user actions:
C#
using SmartBear.TestLeft.TestObjects;
…
public void RemoteTest()
{
string host = "10.0.50.95"; // IP or host name
string user = "domain\\user";
string password = "password";
// Creates a RemoteDriver object
IDriver driver = new RemoteDriver(host, user, password);
// Launches a Notepad on the remote computer
// NOTE: We do not specify the path to Notepad as it is set in the PATH environment variable.
IProcess notepad = driver.Applications.Run("notepad.exe");
// Gets the Notepad's edit box
ITextEdit edit = notepad.Find<ITopLevelWindow>(new WindowPattern()
{
WndClass = "Notepad"
}).Find<ITextEdit>(new WindowPattern()
{
WndClass = "Edit"
});
// Simulates user actions
edit.Click();
edit.SetText("Test");
…
}
Visual Basic .NET
Imports SmartBear.TestLeft.TestObjects
…
Public Sub RemoteTest()
Dim host As String = "10.0.50.95" ' IP or host name
Dim user As String = "domain\user"
Dim password As String = "password"
' Creates a RemoteDriver object
Dim driver As New RemoteDriver(host, user, password)
' Launches a Notepad on the remote computer
' NOTE: We do not specify the path to Notepad as it is set in the PATH environment variable.
Dim notepad As IProcess = driver.Applications.Run("notepad.exe")
' Gets the Notepad's edit box
Dim edit As ITextEdit = notepad.Find(Of ITopLevelWindow)(New WindowPattern() With {
.WndClass = "Notepad"
}).Find(Of ITextEdit)(New WindowPattern() With {
.WndClass = "Edit"
})
' Simulates user actions
edit.Click()
edit.SetText("Test")
…
End Sub
Java
import com.smartbear.testleft.testobjects.*;
…
public void RemoteTest() throws Exception {
String host = "10.0.50.95"; // IP or host name
String user = "domain\\user";
String password = "password";
// Creates a RemoteDriver object
driver = new RemoteDriver(host, user, password);
// Launches a Notepad on the remote computer
// NOTE: We do not specify the path to Notepad as it is set in the PATH environment variable.
TestProcess notepad = driver.getApplications().run("notepad.exe");
// Gets the Notepad's edit box
TextEdit edit = notepad.find(TopLevelWindow.class, new WindowPattern() {{
WndClass = "Notepad";
}}).find(TextEdit.class, new WindowPattern() {{
WndClass = "Edit";
}});
// Simulates user actions
edit.click();
edit.setwText("Test");
…
}
Notes
-
In the code above, we specify the path to the Notepad executable because its location is set in the PATH environment variable. To start your tested application, you may need to specify the path to it. To make your test code portable, use environment variables in the path to the executable file (like
%PROGRAMFILES%
,%APPDATA%
and others). -
To capture and log screenshots of application windows, we recommend using the following methods –
.NET:
Driver.Log.Screenshot
This will decrease the amount of data sent to the test runner and improve TestLeft performance.