simonw / shot-scraper

A command-line utility for taking automated screenshots of websites
https://shot-scraper.datasette.io
Apache License 2.0
1.57k stars 70 forks source link

Fix consistently failing test: Selector with a wait #135

Closed nielthiart closed 4 months ago

nielthiart commented 6 months ago

On moderately slow networks, the "selector with a wait" test fails.

~This commit replaces the --wait 2000 argument with --wait-for "!!document.querySelector('section.secondary')".~

Edit: Reuses the --wait-for test's HTML with a delayed div.

Fixes simonw/shot-scraper#134


📚 Documentation preview 📚: https://shot-scraper--135.org.readthedocs.build/en/135/

simonw commented 5 months ago

I think you forgot to include the examples/div-after-2-seconds.html file.

nielthiart commented 5 months ago

I think you forgot to include the examples/div-after-2-seconds.html file.

The examples/div-after-2-seconds.html is still created by a prior test step, but re-used in the new tests.

nielthiart commented 5 months ago

Thanks for considering this PR. I realised now that I made a different mistake — I removed the original owlsnearme.com test completely, which was not my intention. This commit undoes that.

Hopefully, that will get squashed away on merge, but please let me know if I should squash everything to clean this small change up.

Taken as a whole, this update should now:

  1. Change the Selector with a wait for remote page element test to wait for a section to load, instead of a timed wait.
  2. Add two new tests that wait for a delayed div in examples/div-after-2-seconds.html.

This way we still test timed waiting, just not for remote pages.

simonw commented 4 months ago

Thanks very much for this