【发布时间】:2020-11-17 04:12:41
【问题描述】:
每次量角器元素定位器失败时,它都会打印一个错误,并在我的规范和套件中继续沿着无尽的级联故障的可怕路径。接下来的每个测试都依赖于元素定位器找到它的元素,并且依赖于当前的规范通过。
我想在使用控制台时保持正在测试的网页处于打开状态。目标是调试页面的当前状态并调查元素定位器可能未能找到其目标的原因。
我不太担心整个套件失败并在第一个规范失败时退出(我已经看到了其他关于 --fail-fast 并在第一个规范失败时停止的答案。)这不是我想要的方法采取。我想设置一个断点,并在页面运行时检查环境。
也许doThisOnFailure: () => { debugger } 有类似 Jasmine 的选项,我认为这对我有用。
我真的不喜欢在 afterEach 期间使用规范报告器执行并检查整个规范功能的 Jasmine 环境中失败的规范计数的解决方案。我想立即知道元素定位器何时失败,并在失败后立即中断。
也许真的很恶心的东西会起作用$('element').click().catch(() => { debugger })。
编辑:请注意,我是在询问是否打破规范,而不是在规范结束时打破。
it('should execute deadly code', function () {
p.navigation.openStorageConfigTab()
$$('.bad-selector').get(0).click() /* IMPORTANT: I want to break here */
p.volume.navigateTo()
})
it('should not execute this spec', function () {
$$('.bad-selector').get(0).click()
})
还有输出
✗ should execute deadly code
- Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator By(css selector, .bad-selector)
✗ should not execute this spec
- Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator By(css selector, .bad-selector)
【问题讨论】:
标签: jasmine protractor