wswebcreation / webdriver-image-comparison

MIT License
43 stars 36 forks source link

CSS breakpoint gets triggert when taking a screenshot #64

Closed websaid closed 4 years ago

websaid commented 4 years ago

Environment (please complete the following information):

Config of the automation framework + plugin Run programmatically.

Describe the bug When taking a screenshot, the screen gets resized slightly. If the initial window size is near a css breakpoint, the screenshot might look completly different than expected. (video: https://jmp.sh/JxnTtkA )

To Reproduce Run the code given below.

Expected behavior That the screenshot has the initial look

Additional context Add any other context about the problem here.

const { remote } = require("webdriverio");
const WdioImageComparisonService = require('wdio-image-comparison-service').default;

let env = "asd"
main("Test","ASD")
let testcase = "mainPage"
async function main(testcase, nsc) {
    const browser = await remote({
        "runner": "local",
        "logLevel": "debug",
        "maxInstances": 10,
        "capabilities": {
            "browserName": "chrome",
            'goog:chromeOptions': {
                args: ['--window-size=1020,900'],
            }
        },
        "waitforTimeout": 10000,
        "connectionRetryTimeout": 90000,
        "connectionRetryCount": 3
    });
    let wdioImageComparisonService = new WdioImageComparisonService({
        "savePerInstance": true,
        "clearRuntimeFolder": true,
        "autoSaveBaseline": true,
        "blockOutStatusBar": true,
        "blockOutToolBar": true,
        "disableCSSAnimation": false,
        "fullPageScrollTimeout": 2500,
        "clearFolder": true,
        "formatImageName": `${env.toUpperCase()}_${nsc}_{browserName}_{width}x{height}_${testcase}_{tag}`,
        "screenshotPath": `.tmp/${env.toUpperCase()}/${nsc}`,
    });
    global.browser = browser;
    browser.defaultOptions = wdioImageComparisonService.defaultOptions;
    browser.folders = wdioImageComparisonService.folders
    wdioImageComparisonService.before(browser.capabilities)

    await browser.url("https://saucelabs.com/")

    //Testpart
    let check = await browser.checkScreen("Footer", {
        "fullPageScrollTimeout": 2500
    })
    await browser.deleteSession()
}
wswebcreation commented 4 years ago

@Westsaid

I think this has to do with this default option, https://github.com/wswebcreation/webdriver-image-comparison/blob/master/docs/OPTIONS.md#hidescrollbars

Have you tried turning it off?

websaid commented 4 years ago

@wswebcreation yes, I also tested it with hidescrollbars set to false

wswebcreation commented 4 years ago

Hi @Westsaid

Like in issue https://github.com/wswebcreation/webdriver-image-comparison/issues/62, I can't seem to get the standalone version working, can you also provide a reproducible example in a github project for this one?

wswebcreation commented 4 years ago

I also checked this one, and it works on my machine, see below

ASD_ASD_chrome_1020x900_Test_Footer

The diff might be the fact that Windows is behaving a little bit different here in comparison to Mac

wswebcreation commented 4 years ago

Hi @Westsaid

Any update on this? Otherwise I'll close it in a few days. Thanks

websaid commented 4 years ago

@wswebcreation I will test this on a couple of devices this week, and come back to you. Thanks and have a great week!

websaid commented 4 years ago

Hey, I tested this on a couple of devices now. This bug is just happening on windows, our Mac system had the screenshot correct, just like yours...

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.