question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detect session env options when call attach command

See original GitHub issue

Environment (please complete the following information):

  • WebdriverIO version: 7.1.0
  • Mode: Standalone mode
  • If WDIO Testrunner, running sync/async: async
  • Node.js version: 12.18.1
  • NPM version: 6.14.5

Describe the bug When I attach to android session I doesn’t ses a lot of methods which is available when I create session using remote method.

Example:

const {remote, attach} = require('webdriverio')

let client, client2;

const opts = {
    protocol: 'http',
    hostname: 'localhost',
    port: 4444,
    path: '/wd/hub',
    automationProtocol: 'webdriver',
    capabilities: {
        platformName: 'Android',
        deviceName: 'android',
        version: 'phone-67.0',
        browserVersion: 'phone-67.0',
        browserName: 'chrome'
    }
};

(async function () {
    client = await remote(opts);

    await client.url('https://yandex.ru')

    console.log('client.touchClick:', client.touchClick);
    console.log('client.setOrientation:', client.setOrientation);
    console.log('client.getContext:', client.getContext);

    client2 = await attach({
        sessionId: client.sessionId,
        ...opts
    });

    console.log('client2.touchClick:', client2.touchClick);
    console.log('client2.getOrientation:', client2.getOrientation);
    console.log('client2.getContext:', client2.getContext);

    await client.deleteSession();
})()
    .catch(async (e) => {
        console.error(e.stack)
        await client.deleteSession()
    });

What I see in terminal:

client.touchClick: [AsyncFunction: wrapCommandFn]
client.setOrientation: [AsyncFunction: wrapCommandFn]
client.getContext: [AsyncFunction: wrapCommandFn]
client2.touchClick: undefined
client2.getOrientation: undefined
client2.getContext: undefined

It looks like that problem in method sessionEnvironmentDetector which called inside remote method - https://github.com/webdriverio/webdriverio/blob/main/packages/webdriver/src/index.ts#L55 but not called in attach method - https://github.com/webdriverio/webdriverio/blob/main/packages/webdriver/src/index.ts#L89-L93.

I can pass options isMobile, isW3C and else by hands but it would be much more convenient if sessionEnvironmentDetector will called also in attach method and would be determined by the passed capabilities.

Can I fix this problem or it is desired behaviour?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
christian-bromanncommented, Apr 19, 2021

It seems that it is unnecessary difficult to attach to a running session at the moment, trying something like:

const browser = await remote({
    user: process.env.SAUCE_USERNAME,
    key: process.env.SAUCE_ACCESS_KEY,
    capabilities: {
        browserName: 'chrome'
    }
})

const browser2 = await attach(browser)

even fails the initial design goal of this function due to TypeError: Cannot assign to read only property 'isW3C' of object '#<Browser>'. It would be great if this experience can be improved and all environment flags are properly transferred to the attach session.

Any contributions would be appreciated.

0reactions
christian-bromanncommented, May 27, 2021

Fixed in #6759

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Read and Set Environmental and Shell Variables on ...
The environment is an area that the shell builds every time that it starts a session that contains variables that define system properties....
Read more >
TMUX setting environment variables for sessions
I tried to use the set-environment option which works using the -g option but then sets the variable for all sessions connected to...
Read more >
about Environment Variables - PowerShell | Microsoft Learn
The PowerShell environment provider lets you get, add, change, clear, and delete environment variables in the current console.
Read more >
Environment Variables in Windows/macOS/Linux
An environment variable set via the " set " command under CMD is a local, available to the current CMD session only. Try...
Read more >
Working with Environment Variables in Python - Twilio
In this section I'm going to give you a quick summary of how to set environment variables in a terminal or command prompt...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found