Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 无法将值设置为WebDrivero框架中的表单字段_Node.js_Cucumber_Webdriver Io - Fatal编程技术网

Node.js 无法将值设置为WebDrivero框架中的表单字段

Node.js 无法将值设置为WebDrivero框架中的表单字段,node.js,cucumber,webdriver-io,Node.js,Cucumber,Webdriver Io,我对webdriver io和cucumber框架非常陌生。我用应用程序的登录屏幕进行了第一次测试。我可以调用浏览器并加载网站。但是当我尝试设置登录字段的值时,它抛出以下错误并中止 “执行登录:使用默认用户登录:当我使用默认用户登录时”中的错误 浏览器。$(…).setValue不是函数“ 我试图安装同步软件包并在配置文件中将sync设置为true。我无法使其工作。请帮忙 这是我的配置文件 exports.config={ // // ==================== // Runner

我对webdriver io和cucumber框架非常陌生。我用应用程序的登录屏幕进行了第一次测试。我可以调用浏览器并加载网站。但是当我尝试设置登录字段的值时,它抛出以下错误并中止

“执行登录:使用默认用户登录:当我使用默认用户登录时”中的错误 浏览器。$(…).setValue不是函数“

我试图安装同步软件包并在配置文件中将sync设置为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.
},
//
// ====================
//转轮配置
// ====================
//
//WebdriverIO允许它在任意位置(例如本地或本地)运行测试
//在远程机器上)。
跑步者:“本地”,
//
路径:'/wd/hub',
规格:[
“./features/*.feature”
],
//要排除的模式。
排除:[
//“路径/到/排除/文件”
],
//
最大实例:10,
能力:[{
//每个功能都可以覆盖maxInstances
//网格中只有5个firefox实例可用,您可以确保
//一次启动5个实例。
最大实例:5,
//
browserName:“firefox”,
//如果提供outputDir,WebDrivero可以捕获驱动程序会话日志
//可以配置要包括/排除的日志类型。
//excludeDriverLogs:['*',//传递'*'以排除所有驱动程序会话日志
//excludeDriverLogs:['bugreport','server'],
}],
日志级别:“信息”,
是的,
保释金:0,
baseUrl:“**********************”,
//
//所有waitFor*命令的默认超时。
waitforTimeout:10000,
//
//请求的默认超时(毫秒)
//如果浏览器驱动程序或网格未发送响应
connectionRetryTimeout:90000,
//
//默认请求重试次数
connectionRetryCount:3,
服务:['selenium-standalone'],
框架:“黄瓜”,
黄瓜:{
requireModule:['@babel/register'],/(“扩展名:module”)在需要模块(可重复)后需要具有给定扩展名的文件
require:['./step definitions/*.js'],//(file/dir)在执行功能之前需要文件
回溯:false,//显示错误的完整回溯
dryRun:false,//在不执行步骤的情况下调用格式化程序
//编译器:['js:babel核心/寄存器'],
failFast:false,//第一次失败时中止运行
格式:['pretty'],/(键入[:path])指定输出格式,可以选择提供重定向格式化程序输出的路径(可重复)
snippets:true,//隐藏挂起步骤的步骤定义片段
source:true,//隐藏源URI
配置文件:[],/(名称)指定要使用的配置文件
strict:false,//如果存在任何未定义或挂起的步骤,则失败
tagExpression:“”,//(表达式)仅执行标记与表达式匹配的功能或方案
超时:60000,//步骤定义超时
ignoreUndefinedDefinitions:false,//启用此配置将未定义的定义视为警告。
},

试着执行这个简单的测试用例:

describe("webdriver.io page", () => {
it("should have the right title", () => {
    browser.url('https://www.google.com');
    browser.maximizeWindow();
    $('input[name="q"]').setValue('some text');
    });
});
您能发布您的测试用例示例吗

例如:

When('user enters valid username', () => {
  loginPage.emailAddress.addValue('some text');
});

其中loginPage是一个页面对象,其中包含emailAddress作为元素。

尝试执行以下简单测试用例:

describe("webdriver.io page", () => {
it("should have the right title", () => {
    browser.url('https://www.google.com');
    browser.maximizeWindow();
    $('input[name="q"]').setValue('some text');
    });
});
您能发布您的测试用例示例吗

例如:

When('user enters valid username', () => {
  loginPage.emailAddress.addValue('some text');
});

其中,loginPage是包含电子邮件地址作为元素的页面对象。

欢迎使用Stack overflow。您在问题中给出的相关细节越多,您得到答案的时间越早

据我所知,问题可能是以下三个问题中的任何一个

1) setValue对元素无效,因为您没有选择正确的元素。您可以尝试改进选择器/定位器

2) 您可以尝试单击文本区域并尝试使用api

3) 您不需要将属性设置为该值。您可以将其保留为默认值“/”


参考:GitHub上的示例

欢迎来到Stack overflow。您在问题中给出的相关细节越多,您得到答案的时间就越早

据我所知,问题可能是以下三个问题中的任何一个

1) setValue对元素无效,因为您没有选择正确的元素。您可以尝试改进选择器/定位器

2) 您可以尝试单击文本区域并尝试使用api

3) 您不需要将属性设置为该值。您可以将其保留为默认值“/”


参考:GitHub上的示例在创建config.js时添加依赖项时,我选择了异步模式运行命令。我删除了工作区并重复了所有步骤。但这次将其更改为同步模式运行命令,并再次编写了相同的代码。一切正常。感谢大家的建议。

我选择了异步模式f或者在创建config.js时添加依赖项时运行命令。我删除了工作区并重复了所有步骤。但这次将其更改为运行命令的同步模式,并再次编写了相同的代码。一切正常。感谢大家的建议。

为Cucumber.Th使用的语言添加一个标记会很有帮助是会使它更容易得到响应。这看起来像javascript?我还建议发布您的实际代码。
setValue不是函数
表示您遇到的问题是您可能使用了错误的函数或拼写错误。查看代码将帮助某人诊断它。是的,我正在使用node.js、 WebDrivero和cuucmber framework。它看起来好多了,而且你得到了回复!你还可以通过标记提高获得答案的机会。在这种情况下,我建议添加节点标记。为你正在使用的Cucumber语言添加标记会很有帮助。