@@ -23,7 +23,7 @@ module Selenium
23
23
module WebDriver
24
24
describe Element , exclusive : { bidi : false , reason : 'Not yet implemented with BiDi' } do
25
25
before do
26
- driver . file_detector = -> ( filename ) { File . join ( __dir__ , filename ) }
26
+ driver . file_detector = lambda ( & :first )
27
27
end
28
28
29
29
after { driver . file_detector = nil }
@@ -35,15 +35,15 @@ module WebDriver
35
35
reason : 'unreliable with downloads' } do
36
36
driver . navigate . to url_for ( 'upload.html' )
37
37
38
- driver . find_element ( id : 'upload' ) . send_keys ( 'element_spec.rb' )
38
+ driver . find_element ( id : 'upload' ) . send_keys ( create_tempfile . path )
39
39
driver . find_element ( id : 'go' ) . click
40
40
wait . until { driver . find_element ( id : 'upload_label' ) . displayed? }
41
41
42
42
driver . switch_to . frame ( 'upload_target' )
43
43
wait . until { !driver . find_element ( xpath : '//body' ) . text . empty? }
44
44
45
45
body = driver . find_element ( xpath : '//body' )
46
- expect ( body . text . scan ( 'Licensed to the Software Freedom Conservancy ' ) . count ) . to eq ( 3 )
46
+ expect ( body . text . scan ( 'This is a dummy test file ' ) . count ) . to eq ( 1 )
47
47
end
48
48
end
49
49
@@ -53,16 +53,18 @@ module WebDriver
53
53
ci : :github ,
54
54
reason : 'unreliable with downloads' } do
55
55
driver . navigate . to url_for ( 'upload_multiple.html' )
56
+ file1 = create_tempfile
57
+ file2 = create_tempfile
56
58
57
- driver . find_element ( id : 'upload' ) . send_keys ( "driver_spec.rb \n element_spec.rb " )
59
+ driver . find_element ( id : 'upload' ) . send_keys ( "#{ file1 . path } \n #{ file2 . path } " )
58
60
driver . find_element ( id : 'go' ) . click
59
61
wait . until { driver . find_element ( id : 'upload_label' ) . displayed? }
60
62
61
63
driver . switch_to . frame ( 'upload_target' )
62
64
wait . until { !driver . find_element ( xpath : '//body' ) . text . empty? }
63
65
64
66
body = driver . find_element ( xpath : '//body' )
65
- expect ( body . text . scan ( 'Licensed to the Software Freedom Conservancy ' ) . count ) . to eq ( 5 )
67
+ expect ( body . text . scan ( 'This is a dummy test file ' ) . count ) . to eq ( 2 )
66
68
end
67
69
end
68
70
end
0 commit comments