Rspec HTML 元素不可见。错误信息
Rspec HTML Element is not visible. Error Message
Rspec 没有看到该元素。
Rspec 错误代码:element not visible
对于代码行 @browser.a(:class => 'testButton btn right show').click
然而,此代码行的测试没问题:
@browser.a(:class => 'testButton btn right show').should exist
除了 .click
和 .should exist
之外,两个代码行完全相同
To test that the element is visible, you need to use visible or present. To fix the issue, you need to make the element visible before you click it.
我使用 .when_present.click
而不是 .click
这是完整的解决方案代码:
@browser.a(:class => 'testButton btn right show').when_present.click
Rspec 没有看到该元素。
Rspec 错误代码:element not visible
对于代码行 @browser.a(:class => 'testButton btn right show').click
然而,此代码行的测试没问题:
@browser.a(:class => 'testButton btn right show').should exist
除了 .click
和 .should exist
To test that the element is visible, you need to use visible or present. To fix the issue, you need to make the element visible before you click it.
我使用 .when_present.click
.click
这是完整的解决方案代码:
@browser.a(:class => 'testButton btn right show').when_present.click