File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
src/com/thoughtworks/selenium/webdriven/commands
test/com/thoughtworks/selenium/corebased Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ private File downloadFile(String name) {
62
62
fos = new FileOutputStream (outputTo );
63
63
Resources .copy (url , fos );
64
64
} catch (IOException e ) {
65
-
65
+ throw new SeleniumException ( "Can't access file to upload: " + url , e );
66
66
}
67
67
68
68
return outputTo ;
Original file line number Diff line number Diff line change 22
22
import com .google .common .io .Files ;
23
23
24
24
import com .thoughtworks .selenium .InternalSelenseTestBase ;
25
+ import com .thoughtworks .selenium .SeleniumException ;
25
26
26
27
import org .junit .Before ;
27
28
import org .junit .Test ;
28
29
29
30
import java .io .File ;
31
+ import java .io .FileNotFoundException ;
30
32
import java .io .IOException ;
31
33
32
34
public class TestAttachFile extends InternalSelenseTestBase {
@@ -57,4 +59,16 @@ public void testAttachFile() throws Exception {
57
59
selenium .selectFrame ("upload_target" );
58
60
assertEquals (selenium .getText ("//body" ), LOREM_IPSUM_TEXT );
59
61
}
62
+
63
+ @ Test
64
+ public void testAttachNonExistingFile () throws Exception {
65
+ selenium .open ("/common/upload.html" );
66
+ try {
67
+ selenium .attachFile ("upload" , testFile .toURI ().toURL ().toString () + "-missing" );
68
+ } catch (SeleniumException expected ) {
69
+ assertTrue (expected .getCause () instanceof IOException );
70
+ return ;
71
+ }
72
+ fail ("Exception expected" );
73
+ }
60
74
}
You can’t perform that action at this time.
0 commit comments