Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blur focus before comparing #8

Open
jamesehearn opened this issue Jun 28, 2019 · 2 comments
Open

Blur focus before comparing #8

jamesehearn opened this issue Jun 28, 2019 · 2 comments

Comments

@jamesehearn
Copy link
Contributor

A problem that I run into is that sometimes the blinking cursor is displayed when the image is created form the web page to be tested, so false positives are sometimes displayed. Worse is that these false positives are intermittent, depending on the exact time the image is created.

What's needed is some kind of way to remove the blinking cursor form the page so it's in an identical state each time.

What I've been doing that has worked so far is (since I'm using this with Selenium) to have Selenium execute document.activeElement.blur(). That removes the focus form the page entirely, right? My JavaScript is a bit rusty/lacking.

Would be even better to have this as a ComparisonOption, that runs the blur JS command before the image is saved, I think.

Anybody else have this issue?

I imagine there are circumstances when you'd want the focus on the page to compare as well, but not for my current project.

Will work on this myself, and let you know if anything comes of it. Thanks for letting me take part!

@vivrichards600
Copy link
Owner

vivrichards600 commented Jun 29, 2019

Unfortunately I've not got an IDE setup at the moment to contribute but will try do so soon. Having tried the above .blur() script within the console of DevTools it seems to work.

I remember previously having issues with the cursor blinking but never looked in to it much.

Perhaps what you could do is before it takes the snapshot just use the following to execute the javascript?
driver.ExecuteJavaScript('document.activeElement.blur();');

@jamesehearn
Copy link
Contributor Author

For sure, that's what I'm doing now. No problem making it work like that, just trying to slim down the amount of duplicate code & such. Didn't know how much of a problem it was for others as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants