Debug using an interactive session
An interactive session lets you view, interact, and debug any ongoing test session on the App Automate platform.
You will learn:
- What is an interactive session
- Supported OS and frameworks
- How to start an interactive session
- Example of using an interactive session
Overview
As part of running test scripts for testing websites or applications, you may encounter bugs and issues. The typical debugging process involves using verbose logging and assessing the logs for clues that might help us mitigate the issues.
Though this seems a logical approach to resolving an issue, it might not work for all kinds of issues. In some cases, where the test fails due to the presence or absence of a visual element that isn’t factored as part of the test script, the verbose logs would fail to help.
It can also happen that as part of exploratory testing, you decide to add a breakpoint in your test script and start manual testing from that point forward.
Using an interactive session, you can:
- View live test execution on BrowserStack to observe how an Application Under Test (AUT) behaves during test execution. For example, observing how a test script adds product entries to your database app.
- Interact with the application to click buttons, pop-ups, or any other application element while the test is running. For example, adding multiple product entries to your database app in the middle of test execution to check end-user functionality.
Supported OS and Frameworks
The following table lists the supported OS and framework where you can use interactive sessions.
Component | Versions |
---|---|
Android platform | All versions |
iOS platform | v13.4 and above |
Appium Framework | - iOS: Default Appium version - Android OS: All Appium versions |
Interactive debugging
The interactiveDebugging
capability allows you to debug interactively while a session is in progress.
The following table explains how to enable/disable it for various devices:
Platform | Accepted value |
---|---|
Desktop | Default: true . Set false to disable. |
iOS | Default: true . Set false to disable. |
Android | Default: false . Set true to enable. |
video
and interactiveDebugging
capabilities both have to be set to true
to enable interactive debugging.
Start an Interactive Session
To start an interactive session for any test on the App Automate dashboard, you need to complete the following steps:
- Run your test script in your IDE.
- Navigate to your ongoing App Automate session page and click
Start an interactive session
. - After an interactive session starts, perform any manual testing task in the interactive window on the App Automate session page.
- Stop the manual testing session by clicking
Stop Interactive Session
.
To see an example interactive session, refer to the following section.
See interactive session in action
To understand an interactive session better, consider a Node.js script that opens the Wikipedia app, enters BrowserStack
in the app’s search box, and checks whether the search results appear.
We will add a breakpoint using our IDE after the point in the test script flow where BrowserStack
is entered in the app’s search box. When the test script execution reaches this breakpoint, we will start an interactive session to pause the automated flow of the test script, replace BrowserStack
with any search query in the app’s search box, and then stop the interactive session.
Prerequisites
Before you begin, ensure that the following prerequisites are completed:
- Node.js installed on your machine.
- Node.js project is created in your IDE.
- IDE installed on your machine for adding a breakpoint and running code in the debugger mode. Check out the following links to learn how to add breakpoints in some popular IDEs:
- Visual Studio Code
- Eclipse
-
IntelliJ
This example uses Visual Studio Code.
Upload Wikipedia app to App Automate
Download the Wikipedia app and run the cURL command in your terminal to upload the app to App Automate.
After you run the cURL command, a sample app URL is displayed in your terminal:
{
"app_url":"bs://f7c874e21852ba57957d3fdc33f47514288c4ba4"
}
Start debugging in an Interactive Session
To start an interactive session, complete the following steps:
- Open a Node.js project in the IDE, create a test script file, for example,
sample.js
, and add the following example code to the file:
Note: Replace<app_url>
with the app URL received in your terminal after you have uploaded the app to App Automate.sample.jsvar wd = require('wd'); var assert = require('assert'); var asserters = wd.asserters; desiredCaps = { 'browserstack.user' : 'YOUR_USERNAME', 'browserstack.key' : 'YOUR_ACCESS_KEY', 'build' : 'Node Android', 'name': 'single_test', 'device' : 'Samsung Galaxy S10', 'os_version' : '9.0', 'interactiveDebugging' : true, 'browserstack.debug' : true, 'app' : '<app_url>', // replace <app_url> with the app URL received in the terminal }; driver = wd.promiseRemote("https://hub-cloud.browserstack.com/wd/hub"); driver .init(desiredCaps) .then(function () { return driver.waitForElementByAccessibilityId('Search Wikipedia', asserters.isDisplayed && asserters.isEnabled, 30000); }) .then(function (searchElement) { return searchElement.click(); }) .then(function () { return driver.waitForElementById('org.wikipedia.alpha:id/search_src_text', asserters.isDisplayed && asserters.isEnabled, 30000); }) .then(function (searchInput) { return searchInput.sendKeys("BrowserStack"); }) .then(function () { return driver.elementsByClassName('android.widget.TextView'); // Add a breakpoint here }) .then(function (search_results) { assert(search_results.length > 0); }) .fin(function() { return driver.quit(); }) .done();
-
Add a breakpoint at the line commented as
// Add a breakpoint here
in the example code to pause the test execution afterBrowserStack
is entered in the search box.
Check out the using breakpoints guide to learn how to add a breakpoint in Visual Studio Code. -
Run the code in the debugger mode of the IDE.
Check out the start debugging guide to learn how to run a code in a debugger code in Visual Studio code.
Note: A session can be debugged at a breakpoint for a default timeout of a maximum of 90 seconds. After 90 seconds, the session stops running and displays theBROWSERSTACK_IDLE_TIMEOUT
error in theText Logs
section of your App Automate session page. To increase the default timeout duration, check out the increase timeout duration section. -
Go to your App Automate dashboard and navigate to the ongoing session.
- On your ongoing session page, click Start an interactive session. An interactive session starts where you can interact with the device to perform any manual testing tasks.
- In the app’s search bar of the device, replace
BrowserStack
with any search query, for example,cloud testing
. After your perform any manual tests, click Stop Interactive Session to exit the interactive mode. - In the IDE, click the Continue icon on the Debug toolbar to resume the test script execution.
The test execution resumes from the point where you stopped your interaction. View the video recording of your test session on the App Automate dashboard.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!