Skip to main content

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:

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.
Note: The interactive session feature currently doesn’t support inspecting mobile application elements on the App Automate dashboard. However, an inspection of mobile app elements is supported via Appium desktop in App Automate. Check out the Interactive Debugging guide for more information.

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
Appium Framework v1.17.0
Important: Starting an interactive session on iOS devices is currently not supported.

Start an Interactive Session

To start an interactive session for any test on the App Automate dashboard, you need to complete the following steps:

  1. Run your test script in your IDE.
  2. Navigate to your ongoing App Automate session page and click Start an interactive session.
  3. After an interactive session starts, perform any manual testing task in the interactive window on the App Automate session page.
  4. Stop the manual testing session by clicking Stop Interactive Session.
Important: Interactive session is not supported on test session that uses no-network or airplane-mode network profiles for simulating offline network condition on the device.

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:

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:

  1. 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.js
       var 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 S8 Plus',
         'app' : '<app_url>', // replace <app_url> with the app URL received in the terminal
         'browserstack.debug' : true
       };
       driver = wd.promiseRemote("http://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();
    
    
  2. Add a breakpoint at the line commented as // Add a breakpoint here in the example code to pause the test execution after BrowserStack is entered in the search box.
    Check out the using breakpoints guide to learn how to add a breakpoint in Visual Studio Code.

  3. 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 the BROWSERSTACK_IDLE_TIMEOUT error in the Text Logs section of your App Automate session page. To increase the default timeout duration, check out the increase timeout duration section.

  4. Go to your App Automate dashboard and navigate to the ongoing session.

  5. On your ongoing session page, click Start an interactive session. start an interactive session on App Automate An interactive session starts where you can interact with the device to perform any manual testing tasks.
  6. 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. Interactive session
  7. 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






Thank you for your valuable feedback

Is this page helping you?

Yes
No

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!

Talk to an Expert
Talk to an Expert