feat: support full-page screenshots#827
Conversation
afomi
commented
Nov 12, 2025
- for ChromeDriver and GeckoDriver
* for ChromeDriver and GeckoDriver
| assert_file_exists(path) | ||
|
|
||
| # Verify the file is a valid PNG by checking the PNG signature | ||
| {:ok, file_content} = File.read(path) |
There was a problem hiding this comment.
I would just use File.read! here, so if it fails, it fails with the right error and not a match error.
| ensure_setting_is_reset(:wallaby, :screenshot_dir) | ||
| Application.put_env(:wallaby, :screenshot_dir, screenshots_path) | ||
|
|
||
| [path] = |
There was a problem hiding this comment.
| [path] = | |
| assert [path] = |
|
|
||
| # Verify the file is a valid PNG by checking the PNG signature | ||
| {:ok, file_content} = File.read(path) | ||
| <<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, _rest::binary>> = file_content |
There was a problem hiding this comment.
| <<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, _rest::binary>> = file_content | |
| assert <<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, _rest::binary>> = file_content |
| Application.put_env(:wallaby, :screenshot_dir, screenshots_path) | ||
|
|
||
| # Both of these should work the same way (viewport screenshot) | ||
| [path1] = page |> take_screenshot(name: "test1") |> Map.get(:screenshots) |
There was a problem hiding this comment.
| [path1] = page |> take_screenshot(name: "test1") |> Map.get(:screenshots) | |
| assert [path1] = page |> take_screenshot(name: "test1") |> Map.get(:screenshots) |
|
|
||
| # Both of these should work the same way (viewport screenshot) | ||
| [path1] = page |> take_screenshot(name: "test1") |> Map.get(:screenshots) | ||
| [path2] = page |> take_screenshot(name: "test2", full_page: false) |> Map.get(:screenshots) |
There was a problem hiding this comment.
| [path2] = page |> take_screenshot(name: "test2", full_page: false) |> Map.get(:screenshots) | |
| assert [path2] = page |> take_screenshot(name: "test2", full_page: false) |> Map.get(:screenshots) |
| - Chrome: Uses Chrome DevTools Protocol (CDP) for native fullpage capture | ||
| - Firefox: Uses GeckoDriver's Moz-specific fullpage screenshot endpoint |
There was a problem hiding this comment.
Is this information relevant? I feel like implies to the user that they should know how these things work, but the respective webdriver takes care of it.
There was a problem hiding this comment.
It might be useful to indicate which versions of the webdriver that supports this functionality
|
|
||
| @doc false | ||
| def take_fullpage_screenshot(session_or_element) do | ||
| WebdriverClient.take_fullpage_screenshot_moz(session_or_element) |
There was a problem hiding this comment.
So, selenium is not only used for Firefox. You can use it with any browser/web driver it supports. I think this code won't work if you use selenium with chrome.