wswebcreation / webdriver-image-comparison

MIT License
43 stars 36 forks source link

Use case for hideElements #52

Closed nathasm closed 4 years ago

nathasm commented 4 years ago

I have a page that contains the following snippet:

<div id="infoGraphics">....</div>

Using chrome devtools:

document.querySelectorAll('div#infoGraphics').length
-> 1

In writing my test I have a getter in my page object like:

get infoGraphic() { return $('div#infoGraphics'); }

And my test:

browser.saveScreen('LoginPage', { hideElements: [ LoginPage.infoGraphic ] });

Which fails with:

Cannot set property 'visibility' of undefined

However, if I use the following, my test will work:

get infoGraphic() { return $$('div#infoGraphics'); }

Is this expected? Or have I misused the API?

wswebcreation commented 4 years ago

Hi @nathasm

That is strange, I'll take a look, but it should work. Let me get back to this

wswebcreation commented 4 years ago

Issue is in here https://github.com/wswebcreation/webdriver-image-comparison/blob/60e91fb1a286e20a641a37c0d642d53cd8ecaa2e/lib/clientSideScripts/hideRemoveElements.ts#L5

Need to find some time and fix it

wswebcreation commented 4 years ago

@nathasm

I've release https://github.com/wswebcreation/wdio-image-comparison-service/releases/tag/v1.12.1, can you please check again?

wswebcreation commented 4 years ago

@nathasm

Did you already had time to check it again? I think it might be fixed now.

Christopher-Hayes commented 4 years ago

I'm having the same issue with multiple classes $('.classA.classB'). I'm gonna try upgrading to v1.12.1 (v1.9.0 right now) and report back if that issue is fixed.

Somewhat related, could we make this fail gracefully by still taking the screenshot? 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 now I create a removeElements array by first checking isDisplayed() before passing that to the saveFullPageScreen() function.

LMK if this ^ is a possibility, I can go ahead and make that into a separate ticket.

wswebcreation commented 4 years ago

@Christopher-Hayes

Good suggestion, please make a separate ticket for it

wswebcreation commented 4 years ago

Closing this issue because I believe it is fixed