Skip to content

Commit

Permalink
webdriven: attachFile should throw an exception if the file is not fo…
Browse files Browse the repository at this point in the history
…und or can't be accessed
  • Loading branch information
barancev committed Jun 2, 2015
1 parent 437725c commit c0e91b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private File downloadFile(String name) {
fos = new FileOutputStream(outputTo);
Resources.copy(url, fos);
} catch (IOException e) {

throw new SeleniumException("Can't access file to upload: " + url, e);
}

return outputTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import com.google.common.io.Files;

import com.thoughtworks.selenium.InternalSelenseTestBase;
import com.thoughtworks.selenium.SeleniumException;

import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class TestAttachFile extends InternalSelenseTestBase {
Expand Down Expand Up @@ -57,4 +59,16 @@ public void testAttachFile() throws Exception {
selenium.selectFrame("upload_target");
assertEquals(selenium.getText("//body"), LOREM_IPSUM_TEXT);
}

@Test
public void testAttachNonExistingFile() throws Exception {
selenium.open("/common/upload.html");
try {
selenium.attachFile("upload", testFile.toURI().toURL().toString() + "-missing");
} catch (SeleniumException expected) {
assertTrue(expected.getCause() instanceof IOException);
return;
}
fail("Exception expected");
}
}

0 comments on commit c0e91b9

Please sign in to comment.