【发布时间】:2017-08-18 18:40:22
【问题描述】:
以下步骤测试失败(故意):
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 行中带有 - (即由于上一步失败而未达到)。
谢谢
【问题讨论】:
-
你在用什么 npm 模块?
-
“断言”:“^1.4.1”,“黄瓜”:“^3.0.0”,“phantomjs”:“^2.1.7”,“selenium-webdriver”:“^3.5 .0"
-
这些是我正在使用的一些相关模块。我想这就是你的要求?
-
尝试用
assert.equal(val, true)替换return assert.equal(val, true)看看是否有帮助 -
同样的结果。当步骤静止时抛出错误。
标签: javascript selenium cucumber