Closed DmytroCh closed 2 years ago
The method checkFullPageScreen
can accept an options called hideAfterFirstScroll
. This is an array of elements that will be hidden after the first automatic scroll of the method, see the full options list here
For the rest of the pages you need to fix this yourself because they don't automatically scroll.
Closing this because it's not an issue, but still open for conversation
@wswebcreation thanks! Here is a working code (for interested):
it('should compare successful with full page screen', async() => {
await browser.url('https://webdriver.io/');
const navBar = await $('nav.navbar--fixed-top');
const screenShot = await browser.checkFullPageScreen('examplePaged', {
hideAfterFirstScroll: [
navBar
]
});
await expect(screenShot).toEqual(0);
});
it('should compare successful specific DOM element', async() => {
await browser.url('https://webdriver.io/');
const navBar = await $('nav.navbar--fixed-top');
const el = await $('.container .row iframe');
await el.scrollIntoView();
const screenShot = await browser.checkElement(el, 'ytElement', {
hideElements: [
navBar
]
});
await expect(screenShot).toEqual(0);
});
Thanks @DmytroCh for sharing the code!
Environment (please complete the following information):
Config of WebdriverIO + wdio-image-comparison-service
Describe the bug I've noted that screenshots created by
checkFullPageScreen()
andcheckElement()
could be spoiled by element withposition: sticky
(see screenshots). In case ofhttps://webdriver.io/
page top menu (<nav class="navbar navbar--fixed-top">
) has this property and it jump on the screenshots.To Reproduce Use next test cases and check screenshots in
sauceLabsBaseline
folder.Expected behavior
checkFullPageScreen()
should take a screenshot with navbar at the top onlycheckElement()
should take a screenshot of elementAdditional context I was able to get proper screenshots by setting
browser.debug()
during tests execution and removing position property for<nav class="navbar navbar--fixed-top">
This issue could be related to: