public void shouldThrowErrorIfFilesToSelectIsEmpty() { try { driver.selectFiles(fileChooser, new File[0]); failWhenExpectingException(); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo("The array of files to select should not be empty"); } }
public void shouldThrowErrorIfFilesToSelectIsNull() { try { driver.selectFiles(fileChooser, null); failWhenExpectingException(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("The files to select should not be null"); } }
public void shouldThrowErrorWhenSettingCurrentDirectoryInNotShowingJFileChooser() { hideWindow(); try { driver.setCurrentDirectory(fileChooser, userHomeDirectory()); failWhenExpectingException(); } catch (IllegalStateException e) { assertActionFailureDueToNotShowingComponent(e); } }
public void shouldThrowErrorWhenSettingCurrentDirectoryInDisabledJFileChooser() { disableFileChooser(); try { driver.setCurrentDirectory(fileChooser, userHomeDirectory()); failWhenExpectingException(); } catch (IllegalStateException e) { assertActionFailureDueToDisabledComponent(e); } }
public void shouldThrowErrorWhenSelectingFilesInNotShowingJFileChooser() { hideWindow(); try { driver.selectFiles(fileChooser, array(new File("Fake"))); failWhenExpectingException(); } catch (IllegalStateException e) { assertActionFailureDueToNotShowingComponent(e); } }
public void shouldThrowErrorIfAnyFileToSelectIsNull() { try { driver.selectFiles(fileChooser, array(new File("Fake"), null)); failWhenExpectingException(); } catch (NullPointerException e) { assertThat(e.getMessage()) .isEqualTo("The array of files to select should not contain null elements"); } }
public void shouldThrowErrorWhenSelectingFilesAndJFileChooserCannotHandleMultipleSelection() { disableMultipleSelection(); try { driver.selectFiles(fileChooser, array(new File("Fake1"), new File("Fake2"))); failWhenExpectingException(); } catch (IllegalStateException e) { assertThat(e.getMessage()) .contains("Expecting file chooser") .contains("to handle multiple selection"); } }
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(); } }
public void shouldThrowErrorIfJFileChooserCanOnlySelectFoldersAndOneOfFilesToSelectIsFile() { enableMultipleSelection(); File temporaryFolder = newTemporaryFolder(); File temporaryFile = newTemporaryFile(); setFileChooserToSelectDirectoriesOnly(); try { driver.selectFiles(fileChooser, array(temporaryFolder, temporaryFile)); failWhenExpectingException(); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("the file chooser can only open directories"); } finally { temporaryFile.delete(); temporaryFile.delete(); } }