Skip to content

Commit c980607

Browse files
Add Capture Fullpage Screenshot keyword
Implements the fullpage screenshot functionality requested in issue #1459. The keyword captures the entire page content by temporarily resizing the browser window to show the full page height, taking the screenshot, and then restoring the original window size. Features: - Works with all existing screenshot options (EMBED, BASE64, custom filenames) - Supports {index} placeholder for unique filenames - Includes comprehensive unit and acceptance tests - Follows same patterns as existing screenshot keywords This is useful for capturing long pages that require scrolling to see all content, especially helpful for debugging test failures.
1 parent 2eca943 commit c980607

File tree

10 files changed

+5476
-0
lines changed

10 files changed

+5476
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
*** Settings ***
2+
Documentation Tests fullpage screenshots
3+
Suite Setup Go To Page "forms.html"
4+
Resource ../resource.robot
5+
Force Tags Known Issue Internet Explorer
6+
7+
*** Test Cases ***
8+
Capture fullpage screenshot to default location
9+
[Tags] NoGrid
10+
[Documentation]
11+
... LOG 1:5 </td></tr><tr><td colspan="3"><a href="selenium-fullpage-screenshot-1.png"><img src="selenium-fullpage-screenshot-1.png" width="800px"></a>
12+
... LOG 7:5 </td></tr><tr><td colspan="3"><a href="selenium-fullpage-screenshot-2.png"><img src="selenium-fullpage-screenshot-2.png" width="800px"></a>
13+
[Setup] Remove Files ${OUTPUTDIR}/selenium-fullpage-screenshot-*.png
14+
${file} = Capture Fullpage Screenshot
15+
${count} = Count Files In Directory ${OUTPUTDIR} selenium-fullpage-screenshot-*.png
16+
Should Be Equal As Integers ${count} 1
17+
Should Be Equal ${file} ${OUTPUTDIR}${/}selenium-fullpage-screenshot-1.png
18+
Click Link Relative
19+
Wait Until Page Contains Element tag=body
20+
Capture Fullpage Screenshot
21+
${count} = Count Files In Directory ${OUTPUTDIR} selenium-fullpage-screenshot-*.png
22+
Should Be Equal As Integers ${count} 2
23+
24+
Capture fullpage screenshot to custom file
25+
[Setup] Remove Files ${OUTPUTDIR}/custom-fullpage-screenshot.png
26+
Capture Fullpage Screenshot custom-fullpage-screenshot.png
27+
File Should Exist ${OUTPUTDIR}/custom-fullpage-screenshot.png
28+
29+
Capture fullpage screenshot to custom directory
30+
[Setup] Remove Files ${TEMPDIR}/seleniumlibrary-fullpage-screenshot-test.png
31+
Create Directory ${TEMPDIR}
32+
Set Screenshot Directory ${TEMPDIR}
33+
Capture Fullpage Screenshot seleniumlibrary-fullpage-screenshot-test.png
34+
File Should Exist ${TEMPDIR}/seleniumlibrary-fullpage-screenshot-test.png
35+
36+
Capture fullpage screenshot with index
37+
[Setup] Remove Files ${OUTPUTDIR}/fullpage-screenshot-*.png
38+
Capture Fullpage Screenshot fullpage-screenshot-{index}.png
39+
Capture Fullpage Screenshot fullpage-screenshot-{index}.png
40+
File Should Exist ${OUTPUTDIR}/fullpage-screenshot-1.png
41+
File Should Exist ${OUTPUTDIR}/fullpage-screenshot-2.png
42+
43+
Capture fullpage screenshot with formatted index
44+
[Setup] Remove Files ${OUTPUTDIR}/fullpage-screenshot-*.png
45+
Capture Fullpage Screenshot fullpage-screenshot-{index:03}.png
46+
File Should Exist ${OUTPUTDIR}/fullpage-screenshot-001.png
47+
48+
Capture fullpage screenshot embedded
49+
[Setup] Set Screenshot Directory EMBED
50+
${result} = Capture Fullpage Screenshot
51+
Should Be Equal ${result} EMBED
52+
53+
Capture fullpage screenshot base64
54+
[Setup] Set Screenshot Directory BASE64
55+
${result} = Capture Fullpage Screenshot
56+
Should Not Be Empty ${result}
57+
Should Match Regexp ${result} ^[A-Za-z0-9+/=]+$
58+
59+
Capture fullpage screenshot with EMBED filename
60+
[Setup] Set Screenshot Directory EMBED
61+
${result} = Capture Fullpage Screenshot EMBED
62+
Should Be Equal ${result} EMBED
63+
64+
Capture fullpage screenshot with BASE64 filename
65+
[Setup] Set Screenshot Directory EMBED
66+
${result} = Capture Fullpage Screenshot BASE64
67+
Should Not Be Empty ${result}
68+
Should Match Regexp ${result} ^[A-Za-z0-9+/=]+$
69+
70+
Capture fullpage screenshot when no browser
71+
[Setup] Close All Browsers
72+
${result} = Capture Fullpage Screenshot
73+
Should Be Equal ${result} ${None}

geckodriver-1.log

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
1759037209421 geckodriver INFO Listening on 127.0.0.1:64660
2+
1759037209557 mozrunner::runner INFO Running command: MOZ_CRASHREPORTER="1" MOZ_CRASHREPORTER_NO_REPORT="1" MOZ_CRASHREPORTER_SHUTDOWN="1" "/Users/param/.cache/se ... s" "localhost" "-foreground" "-no-remote" "-profile" "/var/folders/hx/hht4dtpj1rj1by5lsf08xy3r0000gn/T/rust_mozprofileFitC7E"
3+
console.warn: services.settings: Ignoring preference override of remote settings server
4+
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
5+
1759037239943 Marionette INFO Marionette enabled
6+
1759037240739 Marionette INFO Listening on port 64698
7+
Read port: 64698
8+
WebDriver BiDi listening on ws://127.0.0.1:64661
9+
1759037241511 RemoteAgent WARN TLS certificate errors will be ignored for this session
10+
[GFX1-]: Calling WaitFlushedEvent::Run: is delayed: 2078

geckodriver-2.log

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
1759037270133 geckodriver INFO Listening on 127.0.0.1:64737
2+
1759037270154 mozrunner::runner INFO Running command: MOZ_CRASHREPORTER="1" MOZ_CRASHREPORTER_NO_REPORT="1" MOZ_CRASHREPORTER_SHUTDOWN="1" "/Users/param/.cache/se ... s" "localhost" "-foreground" "-no-remote" "-profile" "/var/folders/hx/hht4dtpj1rj1by5lsf08xy3r0000gn/T/rust_mozprofileqhYd11"
3+
console.warn: services.settings: Ignoring preference override of remote settings server
4+
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
5+
1759037272570 Marionette INFO Marionette enabled
6+
1759037273295 Marionette INFO Listening on port 64745
7+
Read port: 64745
8+
WebDriver BiDi listening on ws://127.0.0.1:64738
9+
1759037273982 RemoteAgent WARN TLS certificate errors will be ignored for this session
10+
1759037281511 Marionette INFO Stopped listening on port 64745
11+
console.error: "Failed to fetch https://spocs.getpocket.com/user:" "NetworkError when attempting to fetch resource."
12+
console.error: (new TypeError("NetworkError when attempting to fetch resource.", ""))
13+
console.error: (new Error("OHTTP was configured for https://ads.mozilla.org/v1/delete_user but we couldn't fetch a valid config", "moz-src:///browser/modules/ContextId.sys.mjs", 234))
14+
console.warn: TopSitesFeed: Failed to fetch data from MARS server: NetworkError when attempting to fetch resource.
15+
JavaScript error: resource://gre/modules/ObliviousHTTP.sys.mjs, line 105: NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY: Cannot convert primitive JavaScript value into an array arg 2 [nsIObliviousHttpService.newChannel]

0 commit comments

Comments
 (0)