# Not able to capture the screen shot from the browserstack device

**URL:** <https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548>\
**Category:** Support\
**Created:** [March 3, 2025, 9:49am UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548 "2025-03-03T09:49:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![121himanshu](https://discuss.appium.io/letter_avatar_proxy/v4/letter/1/43a26b/32.png) [@121himanshu](https://discuss.appium.io/u/121himanshu)\
**Post date:** [March 3, 2025, 9:49am UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/1 "2025-03-03T09:49:40Z")

</div>

Hi  
I am using browser stack to test one application but on click of force quit button on the application, the device is not responding to getscreenshot() call.  
Getting the below error in logs captured from the browser stack:

```auto
2025-3-3 9:29:33:995 REQUEST [2025-3-3 9:29:33:995] POST /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/actions {"actions":[{"type":"pointer","id":"TapTouch","parameters":{"pointerType":"touch"},"actions":[{"type":"pointerMove","duration":0,"origin":"viewport","x":215,"y":543},{"type":"pointerDown","button":0},{"type":"pause","duration":0},{"type":"pointerUp","button":0}]}]}
2025-3-3 9:29:34:433 RESPONSE {"value":null}
2025-3-3 9:29:34:436 REQUEST [2025-3-3 9:29:34:436] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot {}
2025-3-3 9:29:35:408 RESPONSE {"value":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-selenium-ba148c1b14.png"}
2025-3-3 9:29:37:932 REQUEST [2025-3-3 9:29:37:932] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/source {}
2025-3-3 9:29:38:55 RESPONSE {"value":{"error":"invalid element state","message":"The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed","stacktrace":"InvalidElementStateError: The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed\n at errorFromW3CJsonCode (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)\n at ProxyRequestError.getActualError (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)\n at JWProxy.command (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:273:19)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at XCUITestDriver.proxyCommand (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)\n at XCUITestDriver.getNativePageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:25:17)\n at XCUITestDriver.getPageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:21:10)","screen":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-93df8c0ac0.jpeg"}}
2025-3-3 9:29:41:236 REQUEST [2025-3-3 9:29:41:236] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/source {}
2025-3-3 9:29:41:301 RESPONSE {"value":{"error":"invalid element state","message":"The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed","stacktrace":"InvalidElementStateError: The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed\n at errorFromW3CJsonCode (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)\n at ProxyRequestError.getActualError (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)\n at JWProxy.command (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:273:19)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at XCUITestDriver.proxyCommand (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)\n at XCUITestDriver.getNativePageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:25:17)\n at XCUITestDriver.getPageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:21:10)","screen":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-d81e567690.jpeg"}}
2025-3-3 9:29:41:995 REQUEST [2025-3-3 9:29:41:995] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot {}
2025-3-3 9:29:42:996 RESPONSE {"value":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-selenium-aef41de4d3.png"}
2025-3-3 9:29:44:476 REQUEST [2025-3-3 9:29:44:476] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/source {}
2025-3-3 9:29:44:563 RESPONSE {"value":{"error":"invalid element state","message":"The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed","stacktrace":"InvalidElementStateError: The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed\n at errorFromW3CJsonCode (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)\n at ProxyRequestError.getActualError (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)\n at JWProxy.command (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:273:19)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at XCUITestDriver.proxyCommand (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)\n at XCUITestDriver.getNativePageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:25:17)\n at XCUITestDriver.getPageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:21:10)","screen":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-6772329e90.jpeg"}}
2025-3-3 9:29:47:915 REQUEST [2025-3-3 9:29:47:915] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/source {}
2025-3-3 9:29:48:610 RESPONSE {"value":{"error":"invalid element state","message":"The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed","stacktrace":"InvalidElementStateError: The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed\n at errorFromW3CJsonCode (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)\n at ProxyRequestError.getActualError (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)\n at JWProxy.command (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:273:19)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at XCUITestDriver.proxyCommand (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)\n at XCUITestDriver.getNativePageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:25:17)\n at XCUITestDriver.getPageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:21:10)","screen":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-b09c72208e.jpeg"}}
2025-3-3 9:29:47:690 REQUEST [2025-3-3 9:29:47:690] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot {}
2025-3-3 9:29:48:735 RESPONSE {"value":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-selenium-ff03dadb6d.png"}
2025-3-3 9:29:51:757 REQUEST [2025-3-3 9:29:51:757] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/source {}
2025-3-3 9:29:51:799 RESPONSE {"value":{"error":"invalid element state","message":"The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed","stacktrace":"InvalidElementStateError: The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed\n at errorFromW3CJsonCode (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)\n at ProxyRequestError.getActualError (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)\n at JWProxy.command (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:273:19)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at XCUITestDriver.proxyCommand (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)\n at XCUITestDriver.getNativePageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:25:17)\n at XCUITestDriver.getPageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:21:10)","screen":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-ebda9a14b9.jpeg"}}
2025-3-3 9:29:52:635 REQUEST [2025-3-3 9:29:52:635] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot {}
2025-3-3 9:29:53:660 RESPONSE {"value":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-selenium-273e452364.png"}
2025-3-3 9:29:55:285 REQUEST [2025-3-3 9:29:55:285] GET /session/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/source {}
2025-3-3 9:29:55:347 RESPONSE {"value":{"error":"invalid element state","message":"The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed","stacktrace":"InvalidElementStateError: The application under test with bundle id 'Application 'com.mobily.mobilyapp'' is not running, possibly crashed\n at errorFromW3CJsonCode (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)\n at ProxyRequestError.getActualError (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)\n at JWProxy.command (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:273:19)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at XCUITestDriver.proxyCommand (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)\n at XCUITestDriver.getNativePageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:25:17)\n at XCUITestDriver.getPageSource (/nix/store/h83064gqicshqjg2pmw64xcj7rm7aqgw-appium-1.21.0/node_modules/appium-xcuitest-driver/lib/commands/source.js:21:10)","screen":"https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-757165b95b.jpeg"}}
2025-3-3 9:29:56:867 STOP_SESSION {"status":0,"sessionId":"4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019","value":{"message":"CLIENT_STOPPED_SESSION"},"errorStack":{}}

```

After performing this click i could not interect wiht the app any more.  
Please suggest.

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [March 3, 2025, 10:12am UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/2 "2025-03-03T10:12:56Z")

</div>

> [@121himanshu](#):
>
> `https://app-automate.browserstack.com/s3-debug/browserstack-debug-screenshots-prod-aps1/4ed4b21867f41adab4c6acabe3f9a8ad7c3e4019/screenshot-selenium-aef41de4d3.png`

With this screenshot we see your app NOT running any more. Enable logging to see your crash e.g. `showXcodeLog` or maybe crash possibly caught with some framework that uses app for reporting crashes (ask developers to check).

---

<div class="post-metadata">

**Author:** ![121himanshu](https://discuss.appium.io/letter_avatar_proxy/v4/letter/1/43a26b/32.png) [@121himanshu](https://discuss.appium.io/u/121himanshu)\
**Post date:** [March 7, 2025, 7:34am UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/3 "2025-03-07T07:34:31Z")

</div>

@Aleksei - Its confirmed that application is closed on click of button (Force quit now) but once application is closed is it possible to start interacting with the device on browser stack again in the same session ?  
Note - InvalidElementStateException is happening during any interaction with the screen after force quit.

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [March 7, 2025, 9:06am UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/4 "2025-03-07T09:06:33Z")

</div>

I am navigating on same screen without problem.

In one of mine test I am terminating app under test and swiping and tapping on home screen without issues. Both iOS + Android real devices. BrowserStack never tried.

- appium 2.12.1
- java-client 9.4.0
- xcuitest@7.31.0
- uiautomator2@3.10.0

Example with iOS →   
 ![211abb59d1a76096](https://discuss.appium.io/uploads/default/original/2X/3/3b50a96237943a0f2cbc71ae257a075313800e7f.gif)

---

<div class="post-metadata">

**Author:** ![121himanshu](https://discuss.appium.io/letter_avatar_proxy/v4/letter/1/43a26b/32.png) [@121himanshu](https://discuss.appium.io/u/121himanshu)\
**Post date:** [March 10, 2025, 8:50pm UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/5 "2025-03-10T20:50:06Z")

</div>

@Aleksei - Is it possible to get the Driver.PageSource only when app is running,  
In my code what I am observing, If app is closed Driver.PageSource throws  
InvalidElementStateException and even if I try to get the page source again i could not find any element while running application on browser stack.

---

<div class="post-metadata">

**Author:** ![Aleksei](https://discuss.appium.io/user_avatar/discuss.appium.io/aleksei/32/6267_2.png) [@Aleksei](https://discuss.appium.io/u/Aleksei)\
**Post date:** [March 11, 2025, 9:40am UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/6 "2025-03-11T09:40:29Z")

</div>

Do not have any issue with iOS. Got response as from main screen

```auto
<?xml version="1.0" encoding="UTF-8"?>
<AppiumAUT>
  <XCUIElementTypeApplication type="XCUIElementTypeApplication" name=" " label=" " visible="true" x="0" y="0" width="414" height="896">
    <XCUIElementTypeWindow type="XCUIElementTypeWindow" visible="true" x="0" y="0" width="414" height="896">
      <XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" x="0" y="0" width="414" height="896">
        <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="0" y="0" width="414" height="896">
          <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="0" y="0" width="414" height="100"/>
        </XCUIElementTypeOther>
        <XCUIElementTypeOther type="XCUIElementTypeOther" name="Home screen icons" visible="true" x="0" y="0" width="414" height="896">
          <XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" x="0" y="0" width="414" height="896">
            <XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" x="0" y="0" width="414" height="896">
              <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="828" y="0" width="414" height="896">
                <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="828" y="0" width="414" height="896">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="828" y="0" width="414" height="896">
                    <XCUIElementTypeOther type="XCUIElementTypeOther" name="dewey-search-bar" visible="false" x="828" y="0" width="414" height="142">
                      <XCUIElementTypeSearchField type="XCUIElementTypeSearchField" name="dewey-search-field" visible="false" x="855" y="70" width="360" height="48">
                        <XCUIElementTypeImage type="XCUIElementTypeImage" name="magnifyingglass" label="Search" visible="false" x="967" y="83" width="23" height="22"/>
                      </XCUIElementTypeSearchField>
                    </XCUIElementTypeOther>
                    <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="828" y="0" width="414" height="896">
                      <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="828" y="0" width="414" height="896">
                        <XCUIElementTypeOther type="XCUIElementTypeOther" name="dewey-pod-view" visible="false" x="828" y="0" width="414" height="896">
                          <XCUIElementTypeOther type="XCUIElementTypeOther" name="dewey-pod-expanded" visible="false" x="828" y="0" width="414" height="896"/>
                        </XCUIElementTypeOther>
                      </XCUIElementTypeOther>
                    </XCUIElementTypeOther>
                  </XCUIElementTypeOther>
                  <XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" x="828" y="0" width="414" height="896"/>
                </XCUIElementTypeOther>
              </XCUIElementTypeOther>
              <XCUIElementTypeIcon type="XCUIElementTypeIcon" visible="true" x="0" y="0" width="0" height="0">
                <XCUIElementTypeIcon type="XCUIElementTypeIcon" value="Widget, Stack" name="Weather" label="Weather" visible="true" x="25" y="68" width="173" height="197">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" x="27" y="70" width="169" height="183">
                    <XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" x="27" y="70" width="169" height="169">
                      <XCUIElementTypeOther type="XCUIElementTypeOther" name="widget-stack:&lt;Weather,Maps,Notes&gt;" visible="true" x="27" y="70" width="169" height="169">
                        <XCUIElementTypeScrollView type="XCUIElementTypeScrollView" visible="true" x="27" y="70" width="169" height="169">
                          <XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" x="27" y="70" width="169" height="169">
......

```

Mine code as example what i did (it only high level as functions code hidden)

```auto
        new AppDriver(getDriver()).terminateApp();
        sleep(10000);
        Logger.log(getDriver().getPageSource());
        sleep(10000);

```

---

<div class="post-metadata">

**Author:** ![121himanshu](https://discuss.appium.io/letter_avatar_proxy/v4/letter/1/43a26b/32.png) [@121himanshu](https://discuss.appium.io/u/121himanshu)\
**Post date:** [March 11, 2025, 9:50am UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/7 "2025-03-11T09:50:08Z")

</div>

I suspect it might be working for the real device but on browser stack we create the session using the bundleID of app under test. If app is closed then we are not able to get page source using Driver.GetPagesource() and it always throws InvalidElementStateException, Because of this even though app looks like active on browser stack portal, but appium inspector could not interact with the app anymore and it could not fetch the screen shots , no tap and swipe works, etc.  
Can you try using appium inspector and creating the cloud connection on browser stack ?

---

<div class="post-metadata">

**Author:** ![mykola-mokhnach](https://discuss.appium.io/user_avatar/discuss.appium.io/mykola-mokhnach/32/4578_2.png) [@mykola-mokhnach](https://discuss.appium.io/u/mykola-mokhnach)\
**Post date:** [March 11, 2025, 6:35pm UTC](https://discuss.appium.io/t/not-able-to-capture-the-screen-shot-from-the-browserstack-device/45548/8 "2025-03-11T18:35:55Z")

</div>

WebDriverAgent has a concept of application under test similar to what’s described in [GitHub - appium/appium-mac2-driver: Next-gen Appium macOS driver, backed by Apple XCTest](https://github.com/appium/appium-mac2-driver?tab=readme-ov-file#application-under-test-concept)

In order to avoid the above exception to be thrown the application under test must be explicitly terminated by [appium-xcuitest-driver/docs/reference/execute-methods.md at master · appium/appium-xcuitest-driver · GitHub](https://github.com/appium/appium-xcuitest-driver/blob/master/docs/reference/execute-methods.md#mobile-terminateapp)  
The above API must also be called explicitly even if the app was closed in some other way to notify WDA about the application state change.
