public void shouldThrowErrorIfFileToSelectIsNull() { try { driver.selectFile(fileChooser, null); failWhenExpectingException(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("The file to select should not be null"); } }
public void shouldThrowErrorWhenSelectingFileInNotShowingJFileChooser() { hideWindow(); try { driver.selectFile(fileChooser, new File("Fake")); failWhenExpectingException(); } catch (IllegalStateException e) { assertActionFailureDueToNotShowingComponent(e); } }
public void shouldSelectFile() { File temporaryFile = newTemporaryFile(); try { driver.selectFile(fileChooser, temporaryFile); File selectedFile = selectedFileIn(fileChooser); assertThat(selectedFile).isSameAs(temporaryFile); } finally { temporaryFile.delete(); } }
public void shouldThrowErrorIfJFileChooserCanOnlySelectFilesAndFileToSelectIsFolder() { File temporaryFolder = newTemporaryFolder(); setFileChooserToSelectFilesOny(); try { driver.selectFile(fileChooser, temporaryFolder); failWhenExpectingException(); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("the file chooser cannot open directories"); } finally { temporaryFolder.delete(); } }
public void shouldThrowErrorWhenSelectingFileInDisabledJFileChooser() { File temporaryFile = newTemporaryFile(); disableFileChooser(); try { driver.selectFile(fileChooser, temporaryFile); failWhenExpectingException(); } catch (IllegalStateException e) { assertActionFailureDueToDisabledComponent(e); } finally { temporaryFile.delete(); } }