Control web replay type
Web replay type determines how OpenText Functional Testing for Developers interacts with web applications, either through Device mode (similar to user interactions) or Web mode (using web browser APIs). You can switch the replay type dynamically within your test scripts, allowing you to optimize behavior for different parts of your application.
Web replay modes
Two replay modes are available:
| Mode | Description |
|---|---|
| Device mode | Interactions are performed as if by an actual user device or browser. This mode simulates real user behavior more closely and is useful for testing responsive designs and device-specific functionality. Device mode may be slower due to the simulation overhead. |
| Web mode | Interactions use web browser APIs directly, which can be faster for certain operations. Web mode is useful for testing traditional web applications where direct API access provides better performance. |
When to use each mode
Choose your replay mode based on your testing needs:
Use Device mode when:
-
Testing responsive web design and mobile-friendly layouts.
-
Validating user interactions that depend on device capabilities (touch, gestures).
-
Testing applications with JavaScript that listens to device events.
-
You need to replicate real user behavior as closely as possible.
Use Web mode when:
-
Testing traditional desktop web applications.
-
Performance is critical and you want faster test execution.
-
Testing features that rely on web-specific technologies or APIs.
-
You have legacy tests designed to work with web-based interactions.
Web methods supported in Device mode
Not all web methods work with Device replay mode. Most web operations require Web mode to function correctly. The following operations are supported in Device mode:
-
Clicking - Click actions on any web object
-
Setting text - Setting text in text input fields
-
Radio buttons - Interacting with radio buttons
-
Checkboxes - Interacting with checkboxes
-
Drag and drop - Performing drag and drop operations
-
File upload - Uploading files
Other web methods, such as highlight, close, sync, and others, only work with Web replay mode. This is why it is common to switch back to Web mode after completing Device mode operations, as shown in the examples below.
Switch replay type in your test
You can change the web replay type at any point in your test script using the WebReplaySettings class. This allows you to use different modes for different parts of your application or test workflow.
Example: Click with Device mode
This example switches to Device mode before clicking a button, then switches back to Web mode.
Java
@Test
public void testClick() throws GeneralLeanFtException {
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
browser.navigate("http://www.example.com");
browser.sync();
browser.activate(true);
// Switch to Device mode for device-like interaction
WebReplaySettings.setWebReplayType(WebReplayType.DEVICE);
Button button = browser.describe(Button.class, new ButtonDescription.Builder()
.tagName("BUTTON")
.name("I'm a button")
.buttonType("submit").build());
button.click();
// Switch back to Web mode
WebReplaySettings.setWebReplayType(WebReplayType.WEB);
browser.close();
}
.NET
[TestMethod]
public void TestClick()
{
IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
browser.Navigate("http://www.example.com");
browser.Sync();
browser.Activate(true);
var button = browser.Describe<IButton>(new ButtonDescription
{
TagName = @"BUTTON",
Name = @"I'm a button",
ButtonType = @"submit"
});
// Switch to Device mode for device-like interaction
WebReplaySettings.setWebReplayType(WebReplayType.DEVICE);
button.Click();
// Switch back to Web mode
WebReplaySettings.setWebReplayType(WebReplayType.WEB);
browser.Close();
}
JavaScript
it("should test click with Device mode", function(done) {
var browser;
Web.Browser.launch(Web.BrowserType.Chrome).then(function(launchedBrowser) {
browser = launchedBrowser;
return browser.navigate("http://www.example.com");
}).then(function() {
return browser.sync();
}).then(function() {
return browser.activate(true);
}).then(function() {
// Switch to Device mode for device-like interaction
return Web.WebReplaySettings.setWebReplayType(Web.WebReplayType.DEVICE);
}).then(function() {
var button = browser.$(Web.Button({
tagName: "BUTTON",
name: "I'm a button",
buttonType: "submit"
}));
return button.click();
}).then(function() {
// Switch back to Web mode
return Web.WebReplaySettings.setWebReplayType(Web.WebReplayType.WEB);
}).then(function() {
return browser.close();
});
LFT.whenDone(done);
});
Example: File upload with Device mode
This example demonstrates file upload using Device mode, which is required for certain file operations.
Java
@Test
public void testWebFile() throws GeneralLeanFtException {
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
browser.navigate("http://www.example.com");
browser.sync();
browser.activate(true);
// Switch to Device mode for file upload
WebReplaySettings.setWebReplayType(WebReplayType.DEVICE);
FileField fileField = browser.describe(FileField.class, new FileFieldDescription.Builder()
.tagName("INPUT")
.name("WebFile").build());
fileField.setValue("C:\\\\Users\\\\username\\\\Documents\\\\file.txt");
// Switch back to Web mode
WebReplaySettings.setWebReplayType(WebReplayType.WEB);
browser.close();
}
.NET
[TestMethod]
public void TestWebFile()
{
IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
browser.Navigate("http://www.example.com");
browser.Sync();
browser.Activate(true);
var fileField = browser.Describe<IFileField>(new FileFieldDescription
{
TagName = @"INPUT",
Name = @"WebFile"
});
// Switch to Device mode for file upload
WebReplaySettings.setWebReplayType(WebReplayType.DEVICE);
fileField.SetValue("C:\\\\Users\\\\username\\\\Documents\\\\file.txt");
// Switch back to Web mode
WebReplaySettings.setWebReplayType(WebReplayType.WEB);
browser.Close();
}
For additional code examples and samples, see WebReplayTypeSamples.zip in the product installation directory or the SDK Reference documentation.
Best practices
-
Set replay type early: Configure the replay mode at the beginning of your test or before starting interaction with the application, to ensure consistent behavior.
-
Test both modes: If your application must work in both Device and Web modes, create tests for each mode to validate behavior differences.
-
Document mode changes: When switching modes mid-test, add comments to explain why the change is necessary. This helps with test maintenance.
-
Handle mode-specific issues: Be aware that some interactions may behave differently depending on the replay mode. Test thoroughly after switching modes.
See also:

