javascript - 运行 Cucumber 测试时会抛出错误并使用以下代码段实现未定义的实现
问题描述
在运行 Cucumber/javascript/selenium 网络驱动程序测试时,我得到了一个Undefined. Implement with the following snippet: this.Then(/^I should display "([^"]*)" under the search area$/, function (arg1, callback){ callback(null, 'pending');....
. 在搜索区域输入文字时,系统会在搜索输入框下方显示结果列表。在显示的结果中,我正在寻找带有文本“建筑设计师”的元素。知道为什么这是 undefined 吗?
Feature: Test search
Scenario: List all the items based on input text provide in search
When I typed the following "Building" text in input
Then I should display "Building Designers" under the search area
// 搜索步骤.js
this.When(/^I typed the following "([^"]*)" text in input$/, (text) =>{
return helpers.loadPage('https://www.sometestsite.com')
.then(()=>{
driver.findElement(By.id('search')).sendKeys(text);
})
})
this.Then(/^I should display "([^"]*)"under the search area&/, function (mytxt){
return driver.wait(until.elementsLocated(By.cssSelector("div.SearchResults--result.button")), 50000).getText().then(el => {
console.log("print text here:"+el);
const displayTxt = el;
expect(displayTxt).to.be.eql(mytxt);
});
})
解决方案
this.Then(/^I should display "([^"]*)"under the search area&/, function (mytxt){
最后你有一个 & 而不是 $
推荐阅读
- ibm-midrange - 关于物理/逻辑文件,CPYF 和 CRTDUPOBJ 有什么区别?
- java - 是否可以更新 3.7 eclipse 目标以使用支持 java 11 的 osgi equiknox 实现
- angular - RxJs 和 Angular,我需要从路由中读取两个参数,并且我想使用可管道操作符
- ngrok - Ngrok 错误 '502 bad gateway' - 如何将 Web 服务器指向 5000
- r - 使用长格式数据集计算和绘制标准误差
- xml - 如何使用 xml-rs 在 xml 中获取属性值?
- aws-lambda - Should I create database update function outside of amplify?
- javascript - PostMan 使用 Laravel 获取 JWT 的预请求脚本
- c# - 分离 NpgsqlConnection 的关注点
- wcf - 如何将 Application Insights 添加到 ILogger
将 Unity DI 用于 WCF 服务