首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在webdriverio Cucumber框架中将值设置为窗体字段

无法在webdriverio Cucumber框架中将值设置为窗体字段
EN

Stack Overflow用户
提问于 2020-04-17 20:36:14
回答 4查看 4.6K关注 0票数 1

我对webdriver和黄瓜framework.Tried非常陌生,这是我第一次在应用程序的登录屏幕上进行测试。我能够调用浏览器和网站是loaded.But i当尝试为登录字段设置值时,它抛出以下错误并中止

"Error in“执行登录:使用默认用户登录:当我使用默认用户登录时”浏览器“。$(.).setValue不是一个函数”

我试图安装同步包,并在配置文件中将同步设置为true。无法使它工作。请帮帮忙!

这是我的配置文件

exports.config ={

代码语言:javascript
复制
//
// ====================
// 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.
},
EN

回答 4

Stack Overflow用户

发布于 2020-04-17 22:11:11

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

代码语言:javascript
复制
describe("webdriver.io page", () => {
it("should have the right title", () => {
    browser.url('https://www.google.com');
    browser.maximizeWindow();
    $('input[name="q"]').setValue('some text');
    });
});

你能把你的测试用例发出来吗?

黄瓜例子:

代码语言:javascript
复制
When('user enters valid username', () => {
  loginPage.emailAddress.addValue('some text');
});

其中loginPage是一个包含emailAddress作为元素的PageObject。

票数 0
EN

Stack Overflow用户

发布于 2020-04-21 21:12:23

欢迎来到堆栈溢出。你在问题中给出的相关细节越多,你就越早得到答案。

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

1) setValue不工作于您的元素,因为您没有选择合适的元素。您可以尝试改进选择器/定位器。

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

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

参考:示例存储库 on GitHub

票数 0
EN

Stack Overflow用户

发布于 2020-04-27 19:14:30

在创建config.js .I的同时添加依赖项时,我选择了异步模式来运行命令,删除了工作区并重复了所有步骤,这次将其更改为用于运行命令的同步模式,并编写了与again.everything工作的代码相同的代码。谢谢大家的建议。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61280243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档