File tree Expand file tree Collapse file tree 3 files changed +80
-0
lines changed
test/sanity/issue5020-nested-loop Expand file tree Collapse file tree 3 files changed +80
-0
lines changed Original file line number Diff line number Diff line change
1
+ < html >
2
+ < head >
3
+ < style type ="text/css ">
4
+ .page {
5
+ width : 210mm ;
6
+ height : 297mm ;
7
+ padding : 50px ;
8
+ }
9
+ </ style >
10
+ < script >
11
+ var p = nw . __dirname ;
12
+ var path = require ( 'path' ) ;
13
+ var pdf_path = path . join ( p , "output.pdf" ) ;
14
+ function test ( ) {
15
+ nw . Window . get ( ) . print ( {
16
+ "pdf_path" : pdf_path
17
+ } ) ;
18
+ var fs = require ( 'fs' ) ;
19
+ fs . readdir ( p , function ( err , files ) {
20
+ if ( err ) {
21
+ throw err ;
22
+ }
23
+
24
+ files . map ( function ( file ) {
25
+ return path . join ( p , file ) ;
26
+ } ) . filter ( function ( file ) {
27
+ return fs . statSync ( file ) . isFile ( ) ;
28
+ } ) . forEach ( function ( file ) {
29
+ document . getElementById ( 'ret' ) . innerHTML += file + "<br/>" ;
30
+ } ) ;
31
+ } ) ;
32
+ fs . watch ( p , ( eventType , filename ) => {
33
+ if ( filename ) {
34
+ document . getElementById ( 'ret' ) . innerHTML = `filename: ${ filename } ; event: ${ eventType } ` ;
35
+ }
36
+ } ) ;
37
+ }
38
+ </ script >
39
+ </ head >
40
+ < body >
41
+ < p id ="ret "> </ p >
42
+ < button onclick ="test() "> test</ button >
43
+ < div class ="page "> page1</ div >
44
+ </ body >
45
+ </ html >
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" :" test-print" ,
3
+ "main" :" index.html"
4
+ }
Original file line number Diff line number Diff line change
1
+ import time
2
+ import os
3
+ import sys
4
+ from selenium .webdriver .common .by import By
5
+
6
+ sys .path .append (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
7
+ from nw_util import *
8
+
9
+ from selenium import webdriver
10
+ from selenium .webdriver .chrome .options import Options
11
+ chrome_options = Options ()
12
+ chrome_options .add_argument ("nwapp=" + os .path .dirname (os .path .abspath (__file__ )))
13
+ testdir = os .path .dirname (os .path .abspath (__file__ ))
14
+ os .chdir (testdir )
15
+ try :
16
+ os .remove ('output.pdf' )
17
+ except :
18
+ pass
19
+
20
+ driver = webdriver .Chrome (executable_path = os .environ ['CHROMEDRIVER' ], chrome_options = chrome_options )
21
+ try :
22
+ print driver .current_url
23
+ driver .find_element (By .XPATH , '//button[text()="test"]' ).click ()
24
+ wait_for_element_id_content (driver , 'ret' , 'output.pdf' , 20 )
25
+ time .sleep (2 )
26
+ os .remove ('output.pdf' )
27
+ result = driver .find_element_by_id ('ret' ).get_attribute ('innerHTML' )
28
+ print result
29
+ assert ("filename: output.pdf; event: rename" == result )
30
+ finally :
31
+ driver .quit ()
You can’t perform that action at this time.
0 commit comments