Javascript WebDrivero-在Google Chrome上运行时的奇怪行为
我一直在为我们的项目使用JavaScript和Cucumber与wdio合作 chrome选项似乎没有任何效果。Chrome浏览器不会启动最大化Javascript WebDrivero-在Google Chrome上运行时的奇怪行为,javascript,selenium-chromedriver,webdriver-io,Javascript,Selenium Chromedriver,Webdriver Io,我一直在为我们的项目使用JavaScript和Cucumber与wdio合作 chrome选项似乎没有任何效果。Chrome浏览器不会启动最大化 goog:chromeOptions': { args: ['--start-maximized'] } 在这个网站的一些地方,我看到一个人提到使用“禁用gpu”的选项,我也尝试过,没有效果 当脚本在浏览器上运行时,奇怪的行为是,它通过挤压屏幕来执行每个操作。我想知道,可能是因为不兼容,因此将每个npm包更新为最新版本,但它的行为方式仍然相同 使用
goog:chromeOptions': {
args: ['--start-maximized']
}
在这个网站的一些地方,我看到一个人提到使用“禁用gpu”的选项,我也尝试过,没有效果
当脚本在浏览器上运行时,奇怪的行为是,它通过挤压屏幕来执行每个操作。我想知道,可能是因为不兼容,因此将每个npm包更新为最新版本,但它的行为方式仍然相同
使用的版本-
WebDriver Version: 6.3.5
Chrome Driver Version: 84.0.1
Google Chrome Version: 84.0.4147.105
package.json依赖项-
"devDependencies": {
"@wdio/cli": "^6.3.6",
"@wdio/cucumber-framework": "^6.3.0",
"@wdio/local-runner": "^6.3.6",
"chromedriver": "^84.0.1",
"cucumber-html-reporter": "^5.2.0",
"eslint": "^7.2.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"wdio-cucumber-framework": "^2.2.8",
"wdio-cucumber-reporter": "0.0.2",
"wdio-cucumberjs-json-reporter": "^2.0.2",
"wdio-firefox-profile-service": "^0.1.3",
"wdio-selenium-standalone-service": "0.0.12",
"wdio-viewport-size": "^1.0.1",
"webdriver-manager": "^12.1.7",
"webdriverio": "^6.3.5"
},
"dependencies": {
"@wdio/sync": "^6.3.6",
"axios": "^0.19.2",
"chai": "^4.2.0",
"chance": "^1.1.6",
"cucumber": "^6.0.5",
"cucumber-pretty": "^6.0.0",
"fs-extra": "^9.0.1",
"knex": "^0.21.1",
"lodash": "^4.17.15",
"moment": "^2.26.0",
"multiple-cucumber-html-reporter": "^1.18.0",
"postgres": "^1.0.2",
"ramda": "^0.27.0",
"rimraf": "^3.0.2",
"underscore": "^1.10.2",
"wdio": "^4.0.0",
}
wdio.conf.js文件-
const cucumberJSON = require('wdio-cucumberjs-json-reporter')
const multipleCucumberHtmlReporter = require('multiple-cucumber-html-reporter')
const moment = require('moment')
const { removeSync } = require('fs-extra')
exports.config = {
runner: 'local',
specs: [
'./features/E2E/E2E.feature'
],
exclude: [
],
maxInstances: 10,
services: ['selenium-standalone'],
capabilities: [{
maxInstances: 5,
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--start-maximized']
},
'cjson:metadata': {
// For a browser
browser: {
name: 'chrome',
version: '58'
},
device: 'HP Elite',
platform: {
name: 'windows',
version: '10'
}
}
}],
logLevel: 'debug',
bail: 0,
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ['selenium-standalone'],
framework: 'cucumber',
reporters: ['cucumberjs-json'],
cucumberOpts: {
require: ['./stepDefinitions/given.js', './stepDefinitions/when.js', './stepDefinitions/then.js'],
backtrace: true,
requireModule: [],
dryRun: false,
failFast: false,
format: ['pretty'],
snippets: true,
source: true,
profile: [],
strict: true,
tagExpression: '@E2E',
timeout: 60000,
ignoreUndefinedDefinitions: false
},
onPrepare () {
removeSync('.tmp/')
console.log('Starting cucumber tests')
},
async afterStep () {
await browser.takeScreenshot().then((val) => {
cucumberJSON.default.attach(val, 'image/png')
}).catch((err) => {
console.log('Error in capturing screenshots', err)
})
},
onComplete () {
multipleCucumberHtmlReporter.generate({
openReportInBrowser: true,
reportName: 'Project Report',
screenshotPath: './reports/screenshots/',
displayDuration: true,
saveCollectedJSON: false,
jsonDir: '.tmp/json/',
reportPath: './reports/',
customData: {
title: 'Project Data',
data: [
{ label: 'Project', value: 'Project Value'},
{ label: 'Release', value: '1.0' },
{ label: 'Execution Start Date', value: moment().format('dddd, MMMM Do YYYY') }
]
}
})
}
}
谁能帮忙吗。我尝试了很多方法,但结果总是一样的。也许我做错了什么。请指导。我想我明白了,为什么它不起作用了。我已按照以下步骤解决问题。希望它能帮助那些面临同样问题的人
npx wdio配置
chromdriver
而不是selenium standalone
Starting cucumber tests
Starting ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
我真的不知道为什么它会这样奇怪,因为Selenium standalone确实包含chromeDriver。如果有人知道这个问题的答案,请补充一句,这将是伟大的学习 我想我明白了,为什么它不起作用了。我已按照以下步骤解决问题。希望它能帮助那些面临同样问题的人
npx wdio配置
chromdriver
而不是selenium standalone
Starting cucumber tests
Starting ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
我真的不知道为什么它会这样奇怪,因为Selenium standalone确实包含chromeDriver。如果有人知道这个问题的答案,请补充一句,这将是伟大的学习