2017-08-17 213 views
0

以下步驟測試失敗(故意)未按:黃瓜步驟上錯誤的步驟

Then(/^the 150 button has been deselected$/, function() { 
    driver.sleep(5000); 
    var checboxValue = driver.findElement(By.css('#app > div > div > div > div.col-xs-offset-2.col-xs-10 > div > div > div:nth-child(3) > div:nth-child(1) > div:nth-child(6) > div > label:nth-child(2) > input[type="checkbox"]')) 
    checboxValue.isSelected() 
     .then((val) => { return assert.equal(val, true) }) 
    }) 

然而,在命令行上述步驟通行證但以下步驟失敗(以正確的/預期的錯誤消息):

When(/^Date 1 is entered$/, function() { 
    var dateInput1 = driver.findElement(By.css('#app > div > div > div > div.col-xs-offset-2.col-xs-10 > div > div > div:nth-child(3) > div:nth-child(1) > div:nth-child(5) > div > div:nth-child(1) > input')); 
    dateInput1.click(); 
    driver.sleep(8000); 
    return dateInput1.sendKeys('2017-07-13'); 
    }) 

這裏的將會發生什麼,在命令行:

(tick)Then the 150 button has been deselected # features\step_definitions\task_2.js:23 
    × When Date 1 is entered # features\step_definitions\task_2.js:30 
     AssertionError: false == true 
      + expected - actual 

      -false 
      +true 

發生了什麼事這裏?對我而言,'Then'步驟應該失敗,'When'步驟應該在cmd行中以藍​​色顯示 - (即,由於上一步失敗未達到)。

感謝

+0

您使用的是哪些npm模塊? –

+0

「assert」:「^ 1.4.1」,「cucumber」:「^ 3.0.0」,「phantomjs」:「^ 2.1.7」,「selenium-webdriver」:「^ 3.5.0」 –

+0

這些是一些我正在使用的相關模塊。我想這就是你要求的? –

回答

0

嘗試採用這種封裝形式,而不是github.com/djungowski/cucumber-assert。我非常確定它必須採取一些措施來使用它。

var assert = require('cucumber-assert'); 

module.exports = function() { 

    this.Given(/^the field E-Mail is filled with "([^"]*)"/, function (email, callback) { 
     var fieldValue = this.getFieldValue('#password'); 
     assert.equal(fieldValue, email, 'Expected E-Mail to be ' + email).then(callback, callback); 
    }); 

}