@@ -19,27 +19,45 @@ can be slash-separated file paths (even on Windows).
19
19
20
20
The flags are:
21
21
22
- -c
23
- Number of test cases to run concurrently.
22
+ -c
23
+ Number of test cases to run concurrently.
24
24
-d
25
- URL of a Chrome websocket debugger. If omitted, screentest tries to find the
26
- Chrome executable on the system and starts a new instance.
25
+ URL of a Chrome websocket debugger. If omitted, screentest uses the
26
+ Chrome executable on the command path. It will look first for the
27
+ headless-shell binary, which is preferred.
27
28
-headers
28
- HTTP(S) headers to send with each request, as a comma-separated list of name:value.
29
+ HTTP(S) headers to send with each request, as a comma-separated list of name:value.
29
30
-run REGEXP
30
- Run only tests matching regexp.
31
- -o
32
- URL or slash-separated path for output files. If omitted, files are written
33
- to a subdirectory of the user's cache directory. Each test file is given
34
- its own directory, so test names in two files can be identical. But the directory
35
- name is the basename of the test file with the extension removed. Conflicting
36
- file names will overwrite each other.
37
- -u
38
- Instead of comparing screenshots, use the test screenshots to update the
39
- want screenshots. This only makes sense if wantURL is a storage location
40
- like a file path or GCS bucket.
41
- -v
42
- Variables provided to script templates as comma separated KEY:VALUE pairs.
31
+ Run only tests matching regexp.
32
+ -o
33
+ URL or slash-separated path where output files for failing tests are written.
34
+ If omitted, files are written to a subdirectory of the user's cache directory.
35
+ At the start of each run, existing files are removed.
36
+ Each test file is given its own directory, so test names in two files can be identical,
37
+ but the directory name is the basename of the test file with the extension removed, so
38
+ files with identical basenames will overwrite each other.
39
+ -u
40
+ Instead of comparing screenshots, use the test screenshots to update the
41
+ want screenshots. This only makes sense if wantURL is a storage location
42
+ like a file path or GCS bucket.
43
+ -v
44
+ Variables provided to script templates as comma-separated KEY:VALUE pairs.
45
+
46
+ # Headless Chrome
47
+
48
+ Screentest needs a headless Chrome process to render web pages. Although it can use a full
49
+ Chrome browser, we have found the headless-shell build of Chrome to be more reliable.
50
+ Install headless-shell on your local machine with this command:
51
+
52
+ npx @puppeteer/browsers install chrome-headless-shell@VERSION
53
+
54
+ Put the binary on your path and screentest will find it. Omit the -d flag in this case.
55
+
56
+ You can also run headless-shell in docker. We use this command:
57
+
58
+ docker run --detach --rm --network host --shm-size 8G --name headless-shell chromedp/headless-shell:VERSION
59
+
60
+ Then pass "-d ws://localhost:9222" to screentest.
43
61
44
62
# Scripts
45
63
@@ -105,6 +123,11 @@ some other way.
105
123
eval 'document.querySelector(".selector").remove();'
106
124
eval 'window.scrollTo({top: 0});'
107
125
126
+ Use sleep DURATION to pause the browser for the duration. This is a last resort
127
+ for deflaking; prefer to wait for an element.
128
+
129
+ sleep 50ms
130
+
108
131
Use capture [SIZE] [ARG] to create a test case with the properties
109
132
defined in the test case. If present, the first argument to capture must be one of
110
133
'fullscreen', 'viewport' or 'element'. The optional second argument provides
@@ -169,6 +192,8 @@ type options struct {
169
192
}
170
193
171
194
func main () {
195
+ log .SetFlags (0 )
196
+ log .SetPrefix ("screentest: " )
172
197
flag .Usage = func () {
173
198
fmt .Printf ("usage: screentest [flags] testURL wantURL path ...\n " )
174
199
fmt .Printf ("\t testURL is the URL or file path to be tested\n " )
@@ -184,5 +209,7 @@ func main() {
184
209
}
185
210
if err := run (context .Background (), flag .Arg (0 ), flag .Arg (1 ), flag .Args ()[2 :], flags ); err != nil {
186
211
log .Fatal (err )
212
+ } else {
213
+ log .Print ("PASS" )
187
214
}
188
215
}
0 commit comments