【发布时间】:2020-04-17 20:36:14
【问题描述】:
我对 webdriver io 和 cucumber 框架非常陌生。尝试使用应用程序的登录屏幕进行我的第一次测试。我可以调用浏览器并加载网站。但是当我尝试为登录字段设置值时,它会引发以下错误并中止
“执行登录时出错:使用默认用户登录:当我使用默认用户登录时” browser.$(...).setValue 不是函数”
我尝试安装同步包并在配置文件中将同步设置为 true。我无法让它工作。请帮忙!
这是我的配置文件
exports.config = {
//
// ====================
// Runner Configuration
// ====================
//
// WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
// on a remote machine).
runner: 'local',
//
path: '/wd/hub',
specs: [
'./features/*.feature'
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
maxInstances: 10,
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 5,
//
browserName: 'firefox',
// If outputDir is provided WebdriverIO can capture driver session logs
// it is possible to configure which logTypes to include/exclude.
// excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
// excludeDriverLogs: ['bugreport', 'server'],
}],
logLevel: 'info',
sync:true,
bail: 0,
baseUrl: '********************',
//
// Default timeout for all waitFor* commands.
waitforTimeout: 10000,
//
// Default timeout in milliseconds for request
// if browser driver or grid doesn't send response
connectionRetryTimeout: 90000,
//
// Default request retries count
connectionRetryCount: 3,
services: ['selenium-standalone'],
framework: 'cucumber',
cucumberOpts: {
requireModule: ['@babel/register'],// <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
require: ['./step-definitions/*.js'], // <string[]> (file/dir) require files before executing features
backtrace: false, // <boolean> show full backtrace for errors
dryRun: false, // <boolean> invoke formatters without executing steps
//compiler: ['js:babel-core/register'],
failFast: false, // <boolean> abort the run on first failure
format: ['pretty'], // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
snippets: true, // <boolean> hide step definition snippets for pending steps
source: true, // <boolean> hide source uris
profile: [], // <string[]> (name) specify the profile to use
strict: false, // <boolean> fail if there are any undefined or pending steps
tagExpression: '', // <string> (expression) only execute the features or scenarios with tags matching the expression
timeout: 60000, // <number> timeout for step definitions
ignoreUndefinedDefinitions: false, // <boolean> Enable this config to treat undefined definitions as warnings.
},
【问题讨论】:
-
为 Cucumber 使用的语言添加标签会很有帮助。这将使其更有可能得到回应。这看起来像javascript?我还建议发布您的实际代码。
setValue is not a function表示您遇到的问题是您可能错误地使用了该功能或拼写错误。看到代码可以帮助某人诊断它。 -
是的,我正在使用 node.js,webdriverio 和 cucmber 框架。
-
看起来好多了,而且您正在收到回复!您还可以通过标签提高获得答案的机会。在这种情况下,我建议添加 Node 标签。
标签: node.js cucumber webdriver-io