browser.screenshot#
Functions#
complete_page(file_name=None, destination_dir=None, delay_seconds=0.25)
#
Take screenshot of complete page and save as PNG image.
Note
Firefox is recommended browser for complete page screenshots as it executes this in one go. Other browsers can't capture the entire page at once, and so we need to merge screenshots portion by portions – and this is obviously much slower. For example:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name | str | None | Name of the file. If | None |
destination_dir | str | Path | None | Destination directory. If | None |
delay_seconds | float | As we stitch several screenshots together by scrolling down the page, adjust iteration delay to ensure that the screen is updated after each scroll. | 0.25 |
Example
Default file name and destination:
Custom file name and default destination:
Custom file name and destination:
Default file name and custom destination:
Note
When setting a custom file name, screenshots should always be saved as a PNG file with a .png
extension.
element(xpath, file_name=None, destination_dir=None)
#
Take screenshot of visible portion and save as PNG image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xpath | str | XPath of the element. | required |
file_name | str | None | Name of the file. If | None |
destination_dir | str | Path | None | Destination directory. If | None |
Example
Default file name and destination:
Custom file name and default destination:
Custom file name and destination:
Default file name and custom destination:
Note
When setting a custom file name, screenshots should always be saved as a PNG file with a .png
extension.
visible_portion(file_name=None, destination_dir=None)
#
Take screenshot of visible portion and save as PNG image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name | str | None | Name of the file. If | None |
destination_dir | str | Path | None | Destination directory. If | None |
Example
Default file name and destination:
Custom file name and default destination:
Custom file name and destination:
Default file name and custom destination:
Note
When setting a custom file name, screenshots should always be saved as a PNG file with a .png
extension.