wswebcreation / webdriver-image-comparison

MIT License
43 stars 36 forks source link

Feature Request: Screenshot fail gracefully when removeElements non-existing #57

Closed Christopher-Hayes closed 2 years ago

Christopher-Hayes commented 4 years ago

Is your feature request related to a problem? Please describe. I have elements that only exist on certain pages and the library not finding one of the remove elements causes the screenshot to never be taken. For me, it isn't critical that every element in removeElements is removed. I just want the elements that do exist to be removed and non-existing ones to be ignored because some can be intermittent (ex: random sales popup).

Describe the solution you'd like I would like the screenshot function (like saveFullPageScreen()) to first check if an element exists before attempting to remove it, or at least fail in a way that doesn't stop the screenshot from being taken.

Describe alternatives you've considered My current solution is to create a removeElements array ahead of the saveFullPageScreen() by first checking isDisplayed() on each element before passing that to the saveFullPageScreen() options.

Additional context It looks like xPath doesn't like elements that don't exist, causes the function to fail. For context in the error below .lp_promo_banner is the element by trying to hide that doesn't exist on all pages. image If it's useful, my (simplified) function call looks like:

browser.saveFullPageScreen(path, {
    removeElements: [
        $('.lp_promo_banner')
    ]
})
wswebcreation commented 4 years ago

@Christopher-Hayes

Going to fix this with a console warning like this

image

Will be released soon

wswebcreation commented 4 years ago

@Christopher-Hayes

I've released version https://github.com/wswebcreation/wdio-image-comparison-service/releases/tag/v1.13.0. Can you please check it and if fixed close the issue?