browserstack / browserstack-gradle-plugin

Gradle plugin for uploading app and running tests on BrowserStack
16 stars 20 forks source link

Browserstack Console Outputs #65

Closed SachaTe closed 1 year ago

SachaTe commented 1 year ago

I have junit tests written which I am able to run on Browserstack. However when I run on my local system the printouts/console outputs are saved to a file which can be accessed (i.e. logs that are not in device logs, but printed to console), however I am not finding a similar method to retreive them on browserstack.

GrandEL01 commented 1 year ago

Hey,

As per my understanding of what you are trying to achieve I guess these points should help you:

  1. BrowserStack does have a console logs functionality which gives you logs related to the Browser console. You can refer to their API doc link for the same: https://www.browserstack.com/docs/automate/api-reference/selenium/session#get-session-console-logs

On a side note: The console log you are perhaps expecting should be present on your IDE console or CICD console.

  1. Additionally BrowserStack device logs provides logs related to the device on which the execution is taking place. You can set the capability to true and view them on your dashboard. Here is a like for your reference: https://www.browserstack.com/docs/app-automate/appium/debug-failed-tests/device-logs

Furthermore you can retrieve the logs you are looking for in two ways:

  1. From the BrowserStack dashboard itself. You can get device logs network logs etc. by enabling the respective capabilities.
  2. You can make use of the functionalities via REST API referring to their doc: https://www.browserstack.com/docs/automate/api-reference/selenium/introduction

Thanks.

SachaTe commented 1 year ago

Thanks! I am wondering if there is a method of obtaining the BUILD_ID without having to capture the full output and using tools to retrieve the information from the output dump. Any suggestion for that ?

bhumikababbar commented 1 year ago

@SachaTe

https://www.browserstack.com/docs/automate/api-reference/selenium/project#get-project-details

You can make use of the above API call and get the build id (hashed_id) from the response. You can check for the details of all the values in the response under the show values section on the left-hand side.

SachaTe commented 1 year ago

Yes I see that, but if we have 2 parallel builds running at same time there may be an issue in just fetching by most recent build

rahulHbrowserstack commented 1 year ago

When you are executing 2 parallel builds running at the same time, then you can get the details about all the running Builds.

You can check this link for more details: (https://www.browserstack.com/docs/automate/api-reference/selenium/project#get-project-details:~:text=in%20a%20group.-,Get%20project%20details,-GET%20/automate/projects)

You can check the latest build details in the response.

SachaTe commented 1 year ago

I understand how to retrieve information via Browserstack but it does not answer the question at hand. There needs to be a method to obtain the build ID just as its printed to console {"message":"Success","build_id":"<build-id>"} or via View build status at https://app-automate.browserstack.com/builds/<build-id>. This is important as it is the only way to directly link to a test set being executed on browserstack without relying on timestamps, especially in build/test automation. Currently the only way I found to do this was to grab the full output and search through it for this ID which is not optimal, there should be a mechanism which allows it to be fetched once completed successfully (example, sets env variable, etc.)

Maybe a use case will help explain the importance; If you want to have automated build/test setup (i.e. jenkins, github actions, local, etc) you would want to execute executeDebugTestsOnBrowserstack, grab the build-id and then poll on an interval to wait until the tests have finished and retrieve the results. There can be many of these scripts for the same project running in parallel (different users, builds, etc.) so you cannot rely on a timestamps or latest build. The only way to link the current execution to a build is via the returned build id.