在运行Cucumber测试时,使用以下代码段引发错误和未定义的实现

时间:2018-11-06 04:48:59

标签: javascript selenium-webdriver cucumber

在运行Cucumber / javascript / Selenium Web驱动程序测试时,我得到了Undefined. Implement with the following snippet: this.Then(/^I should display "([^"]*)" under the search area$/, function (arg1, callback){ callback(null, 'pending');....。在搜索区域中键入文本时,系统将在搜索输入框下显示结果列表。在显示的结果中,我正在寻找带有文本“ Building Designers”的元素。知道为什么这会以未定义的形式抛出吗?

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

// search-steps.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);        
        });     
    })

enter image description here

1 个答案:

答案 0 :(得分:2)

this.Then(/^I should display "([^"]*)"under the search area&/, function (mytxt){

您在末尾用&而不是$