Closed louis57 closed 3 years ago
Thanks for raising the issue.
Is that command removed in the latest version? or replaced with another one?
Not sure what your setup is but maximizeWindow
only doesn't work when running WebdriverIO with DevTools protocol. If WebdriverIO can't find a browser driver it falls back using the DevTools protocol. So my assumption is that something went wrong with your setup causing it to run via DevTools while actually you want to run using the WebDriver protocol. Make sure you have a browser driver running.
Closing as this is a configuration issue. There is no chance to implement this command using DevTools and Puppeteer (which drivers CDP).
@christian-bromann Thanks for your reply and the explanation. A silly question because I am new to this: how can I configure webdriver to user WebDriver protocol when running?.
This is my wdio.conf.ts
exports.config = {
runner: 'local',
specs: [
'./test/**/*.ts'
],
capabilities: [{
browserName: 'chrome',
maxInstances: 1,
acceptInsecureCerts: true,
}],
framework: 'Jasmine',
jasmineOpts: {
defaultTimeoutInterval: 1200000,
},
autoCompileOpts: {
autoCompile: true,
// for all available options
tsNodeOpts: {
transpileOnly: true,
project: 'tsconfig.json'
},
},
waitforTimeout: 100000,
};
Am I missing something? And how I can configure it to run with WebDriver protocol?
Thanks in advance.
Usually it will automatically pick it if you have a browser driver in place, e.g. via wdio-chromedriver-service
plugin. You can explicitly enforce it by setting the automationProtocol
option.
I have both what you suggested, but somehow it still doesn't work for me.
This is all my dependencies:
"devDependencies": {
"@wdio/cli": "^7.14.1",
"@wdio/jasmine-framework": "^7.14.1",
"@wdio/local-runner": "^7.14.1",
"@wdio/spec-reporter": "^7.14.1",
"chromedriver": "^94.0.0",
"ts-node": "^10.3.0",
"typescript": "^4.4.4",
"wdio-chromedriver-service": "^7.2.2",
"webdriverio": "^7.14.1"
},
"dependencies": {
"webdriver": "^7.14.1"
}
And I also use this flag automationProtocol: 'webdriver'
in wdio.conf.ts
, but still nothing changed.
One thing I noticed, that when I run my tests, the log info looks like this
2021-10-15T12:03:32.684Z INFO devtools: COMMAND findElements("css selector", "#mat-input-14")
2021-10-15T12:03:32.696Z INFO devtools: RESULT []
It seems, as you suggested, the WebDriverIO is using devtools
instead of webdriver
?!
I need to google more. Thanks for your help @christian-bromann
Can you provide a small reproducible example?
Thanks for still staying with me.
I just start to make a small POC of WebDriverIO for my app, so the structure looks simple like this:
You have seen the wdio.conf.ts
, dependencies. This is tsconfig.json
{
"compilerOptions": {
"target": "es2019",
"types": [
"node",
"webdriverio/sync",
"@wdio/jasmine-framework"
]
},
"include": [
"./test/**/*.ts",
]
}
File pwahome.page.ts
class PWAHomePageClass {
get icelandCountry() {
return $("div=Iceland")
}
get englishLanguage() {
return $("img[alt='EN']")
}
get saveButton() {
return $("button*=Save")
}
get submitReportButton() {
return $("i[class='fa-bullhorn fas']")
}
get loginInboxButton() {
return $("i[class='fa-mailbox fas']")
}
}
module.exports = new PWAHomePageClass();
File pwahome.spec.ts
const pwaHomePage = require('../pages/pwahome.page');
describe('PWA Reporting Tool Page', () => {
it('can submit a form', async() => {
await browser.url(url);
await browser.pause(5000);
//await browser.maximizeWindow();
await pwaHomePage.icelandCountry.click();
await pwaHomePage.englishLanguage.click();
await pwaHomePage.saveButton.click();
await pwaHomePage.submitReportButton.click();
});
});
I run test with npx wdio run ./wdio.conf.ts
. Everything is fine, except that command browser.maximizeWindow()
. I don't know why it still runs with devtools
protocol.
Did you setup wdio-chromedriver-service
?
Yes, I did set it up with the latest version "wdio-chromedriver-service": "^7.2.2"
. I can see the package in node_modules
Your wdio.conf.js
doesn't show the service being activated. See also this configuration step. Maybe also worth taking a look at our Jasmine boilerplate project.
Alright, I made it work, thanks to your suggestions :+1: . I added services: ['chromedriver']
to wdio.conf.js
, and downgraded "chromedriver": "^93.0.1"
, (it was 94 before), because I still have Chrome v93 on my machine. And it runs, command browser.maximizeWindow()
works as well. And in output, it shows the tests is running with webdriver
, instead of devtools
like before.
2021-10-15T14:20:21.523Z INFO webdriver: DATA { url: '' }
2021-10-15T14:20:22.067Z INFO webdriver: COMMAND maximizeWindow()
Just a last little thing, even though command browser.maximizeWindow()
works, it is still highlighted as a problem in IDE
I'll figure it out, as long as the test is running. Thank you so much for your time !
A wdio project working 2 or 3 weeks ago now produces the error Command "maximizeWindow" is not yet implemented
.
Chrome was outdated; it is now updated to 112
.
I matched chromedriver to 112
too.
We have wdio-chromedriver-service ^7.3.2
as a devDependency.
The same error reoccurs.
@christian-bromann
sorry for asking many questions.
services: ['chromedriver'],
if I add this line of code in the wdio.conf.js file it does not work. ' FAILED in chrome browser ' error.
otherwise works well.
Could you tell me what may be the reason ?
To fix this, I install chromedriver package and wdio-chromedriver-service. but no effect.
@christian-bromann Could you tell me how I can make chromedriver service works well in webdriver.io test scripts ? I want to know when does chromedriver service not work well.
You don't need Chromedriver service in latest WebdriverIO anymore. If you use an older version of v8 or v7 please refer to the documentation.
@christian-bromann services: ['chromedriver'], if I add this line of code in the wdio.conf.js file it does not work. ' FAILED in chrome browser ' error. otherwise some functions like maximizeWindow() not work. Could you tell me what may be the reason ?
@christian-bromann And if I change some code in wdio.conf.js below error toast appears. I don't find reason. Could you tell me ?
failed load WDIO configuration:Failed to parse config for wdio.conf.js: [stdin]:2 const {framework,specs,exclude=[]} = config ^ TypeError: Cannot destructure property 'framework' of 'config' as it is undefined. at [stdin]:2:12 at Script.runInThisContext (node:vm:129:12) at Object.runInThisContext (node:vm:307:38) at node:internal/process/execution:79:19 at [stdin]-wrapper:6:22 at evalScript (node:internal/process/execution:78:60) at node:internal/main/eval_stdin:30:5 at Socket.
Environment (please complete the following information):
Describe the bug The command
browser.maximizeWindow()
doesn't work any more with latest version WebdriverIO7.14.1
. It throws the following error:It still worked in the version WebdriverIO
7.5.2
.Is that command removed in the latest version? or replaced with another one?