awslabs / wdio-aws-device-farm-service

AWS Device Farm service for WebdriverIO
https://aws.amazon.com/device-farm/
Apache License 2.0
22 stars 8 forks source link

Retrieve session arn or Id after test run #30

Closed ltrung closed 1 year ago

ltrung commented 1 year ago

Hi, Is there a way to retrieve and print out the session arn or id after a test run so that we could lookup the corresponding test in Device Farm console?

arnulfojr commented 1 year ago

Hi,

The session ID can be retrieved through the Browser object https://webdriver.io/docs/api/browser#properties

To build the DeviceFarm session ARN you will need your Project ARN, the following ARN format can be used:

arn:aws:devicefarm:us-west-2:{accountId}:testgrid-project:{TestGridProjectId}

arn:aws:devicefarm:us-west-2:{accountId}:testgrid-session:{TestGridProjectId}/{TestGridSessionId}

Otherwise you can take a look into DeviceFarm public docs

https://docs.aws.amazon.com/devicefarm/latest/testgrid/managing-sessions.html

Resolving issue, feel free to re-open it if you'd have more questions.

robbrad commented 1 year ago

@arnulfojr If im using the wdio testrunner

like this in node

            wdio.run().then(
                exitCode => {
                    process.exit(exitCode);
                },
                error => {
                    console.error('Launcher failed to start the test', error.stacktrace);
                    process.exit(1);
                },
            );

Is there a way I can access the sessionId as you have mentioned?

arnulfojr commented 1 year ago

@arnulfojr If im using the wdio testrunner

like this in node


            wdio.run().then(

                exitCode => {

                    process.exit(exitCode);

                },

                error => {

                    console.error('Launcher failed to start the test', error.stacktrace);

                    process.exit(1);

                },

            );

Is there a way I can access the sessionId as you have mentioned?

Hi,

I believe the problem there is that your runner first needs to instantiate a session. Wdio basically spawns new child processes for each runner which each would create a session, and it would then be available through the Browser global variable.

Afaik it's not possible to access the session from the runner. You would have to access it through the Browser instance.