Skip to content

Commit

Permalink
testlib: Workaound mysterious disappearing buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Feb 20, 2025
1 parent cf3f3f2 commit 18bd608
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,9 +1357,31 @@ def relative_clips(sels: Collection[str]) -> Collection[tuple[int, int, int, int
ref_filename = os.path.join(reference_dir, filename)
self.used_pixel_references.add(ref_filename)
rect["type"] = "box"
# HACK - https://github.com/cockpit-project/cockpit/issues/21577
#
# There is some really evil Chromium bug that often hides the
# primary button in dialogsscreenshots. But funnily, calling
# captureScreenshot a second time will give us the correct
# rendering, every time.
#
# This doesn't seem to be a race between the page changing and
# us taking screenshots. No amount of waiting here helps
# fully. The second call to captureScreenshot seems to indeed
# trigger something that renders the page again, and correctly
# this time.
#
# If the PNG changes from the first call to the second, we
# warn about that. But note that not all these inconsistencies
# would lead to a pixel test failure.
#
ret1 = self.bidi("browsingContext.captureScreenshot", quiet=True,
context=self.driver.top_context,
clip=rect)
ret = self.bidi("browsingContext.captureScreenshot", quiet=True,
context=self.driver.top_context,
clip=rect)
if ret1["data"] != ret["data"]:
print("WARNING: Inconsistent screenshots for", base)
png_now = base64.standard_b64decode(ret["data"])
png_ref = os.path.exists(ref_filename) and open(ref_filename, "rb").read()
if not png_ref:
Expand Down

0 comments on commit 18bd608

Please sign in to comment.