File tree 1 file changed +30
-0
lines changed
examples/javascript/test/interactions
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { Builder} = require ( 'selenium-webdriver' ) ;
2
+ const chrome = require ( 'selenium-webdriver/chrome' ) ;
3
+ const assert = require ( "node:assert" ) ;
4
+ let opts = new chrome . Options ( ) ;
5
+ opts . addArguments ( '--headless' ) ;
6
+
7
+ let startIndex = 0
8
+ let endIndex = 5
9
+ let pdfMagicNumber = 'JVBER'
10
+ let base64Code
11
+
12
+ describe ( 'Interactions - Windows' , function ( ) {
13
+ let driver ;
14
+
15
+ before ( async function ( ) {
16
+ driver = await new Builder ( ) . forBrowser ( 'chrome' ) . setChromeOptions ( opts ) . build ( ) ;
17
+ } ) ;
18
+
19
+ after ( async ( ) => await driver . quit ( ) ) ;
20
+
21
+ it ( 'Should be able to print page to pdf' , async function ( ) {
22
+ await driver . get ( 'https://www.selenium.dev/selenium/web/alerts.html' ) ;
23
+ let base64 = await driver . printPage ( { pageRanges : [ "1-2" ] } ) ;
24
+ // page can be saved as PDF as below
25
+ // await fs.writeFileSync('./test.pdf', base64, 'base64');
26
+
27
+ base64Code = base64 . slice ( startIndex , endIndex )
28
+ assert . strictEqual ( base64Code , pdfMagicNumber )
29
+ } ) ;
30
+ } ) ;
You can’t perform that action at this time.
0 commit comments