1
1
const assert = require ( 'assert' ) ;
2
- const path = require ( 'path' ) ;
2
+
3
+ const { event } = codeceptjs ;
3
4
4
5
Feature ( 'Session' ) ;
5
6
@@ -76,6 +77,28 @@ Scenario('Different cookies for different sessions @WebDriverIO @Protractor @Pla
76
77
assert . notEqual ( cookies . john , cookies . mary ) ;
77
78
} ) ;
78
79
80
+
81
+ Scenario ( 'should save screenshot for active session @WebDriverIO @Puppeteer @Playwright' , async function ( I ) {
82
+ I . amOnPage ( '/form/bug1467' ) ;
83
+ I . saveScreenshot ( 'original.png' ) ;
84
+ I . amOnPage ( '/' ) ;
85
+ session ( 'john' , async ( ) => {
86
+ await I . amOnPage ( '/form/bug1467' ) ;
87
+ event . dispatcher . emit ( event . test . failed , this ) ;
88
+ } ) ;
89
+
90
+ const fileName = clearString ( this . title ) ;
91
+
92
+ const [ original , failed ] = await I . getMD5Digests ( [
93
+ `${ output_dir } /original.png` ,
94
+ `${ output_dir } /${ fileName } .failed.png` ,
95
+ ] ) ;
96
+
97
+ // Assert that screenshots of same page in same session are equal
98
+ assert . equal ( original , failed ) ;
99
+ } ) ;
100
+
101
+
79
102
Scenario ( 'should throw exception and close correctly @WebDriverIO @Protractor @Puppeteer @Playwright' , ( I ) => {
80
103
I . amOnPage ( '/form/bug1467#session1' ) ;
81
104
I . checkOption ( 'Yes' ) ;
@@ -85,6 +108,7 @@ Scenario('should throw exception and close correctly @WebDriverIO @Protractor @P
85
108
I . seeCheckboxIsChecked ( { css : 'input[value=No]' } ) ;
86
109
} ) ;
87
110
I . seeCheckboxIsChecked ( { css : 'input[value=Yes]' } ) ;
111
+ I . amOnPage ( '/info' ) ;
88
112
} ) . fails ( ) ;
89
113
90
114
Scenario ( 'async/await @WebDriverIO @Protractor' , ( I ) => {
@@ -203,3 +227,11 @@ Scenario('should return a value @WebDriverIO @Protractor @Puppeteer @Playwright
203
227
I . click ( 'Submit' ) ;
204
228
I . see ( '[description] => Information' ) ;
205
229
} ) ;
230
+
231
+ function clearString ( str ) {
232
+ if ( ! str ) return '' ;
233
+ /* Replace forbidden symbols in string
234
+ */
235
+ return str
236
+ . replace ( / / g, '_' ) ;
237
+ }
0 commit comments