Detect session env options when call attach command
See original GitHub issueEnvironment (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:
- Created 3 years ago
- Comments:6 (6 by maintainers)
It seems that it is unnecessary difficult to attach to a running session at the moment, trying something like:
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.
Fixed in #6759