Reputation:
When running in headless mode, should the tests make visibilty checks? When I run tests in normal chrome or firefox they all pass, but in headless mode I keep getting this error:
test('Assert navigation from Home to page x...', async t => {
await t
.expect(link.textContent).eql('page x')
.click(link)
.expect(getPageUrl()).contains('pagex')
});
Error: The element that matches the specified selector is not visible.
and when I add expect([someSelector].visibile).ok() I get this error:
AssertionError: expected false to be truthy
I feel my approach to writing these tests for the specific prupose of running them in headless mode is incorrect. I'm not sure if running in headless mode impacts the overall approach to how tests are structured?
I'm writing a number of e2e tests that can integrate into Jenkins so that they run whenever new code is committed.
Upvotes: 3
Views: 1411
Reputation: 1917
You want t.expect(selector.visible).ok()
Visibility simply checks that the element exists in the DOM and does not have a visible: hidden
or display: none
style rule set
Running in headless does not affect this so there might be some other issue.
Upvotes: 4