Web replay types
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.
Replay modes
The following replay modes are available:
| Mode | Description |
|---|---|
| Web mode (Default) |
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. |
| Device mode |
Interactions are performed as if by an actual user mouse or keyboard. This mode simulates real user behavior more closely and is useful for testing responsive designs and device-specific functionality. Device mode supports the following methods: Click, FireEvent, DragAndDropOn, Select (for radio groups), Set (for web files and checkboxes), SetValue and SetSecure (for edit fields). Note:
|
When to use each mode
Choose your replay mode based on your testing needs:
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.
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.
Switch replay type in your test
The Web mode is used by default. The test can change the replay type during the run, using the WebReplaySettings class. This allows you to use different modes for different parts of your application or test workflow.
The mode you switch to remains in effect until the end of the run unless you switch modes again. If you switch to Device mode during the test, remember to switch back to web mode before performing any operations that are not supported by device mode.
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.

