-
-
Notifications
You must be signed in to change notification settings - Fork 209
feat: support full-page screenshots #827
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
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <<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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.