You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UploadNoSelectionTest.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.vaadin.tests.components.upload;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Test;
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.WebElement;
  6. import com.vaadin.tests.tb3.MultiBrowserTest;
  7. public class UploadNoSelectionTest extends MultiBrowserTest {
  8. @Test
  9. public void testUploadNoSelection() throws Exception {
  10. openTestURL();
  11. // empty content is populated by com.vaadin.tests.util.Log
  12. assertEquals(" ", getLogRow(0));
  13. getSubmitButton().click();
  14. // expecting empty file name
  15. assertLogRow(0, 4, UploadNoSelection.FILE_NAME_PREFIX);
  16. // expecting 0-length file
  17. assertLogRow(1, 3, UploadNoSelection.FILE_LENGTH_PREFIX + " " + 0);
  18. assertLogRow(2, 2, UploadNoSelection.UPLOAD_FINISHED);
  19. assertLogRow(3, 1, UploadNoSelection.RECEIVING_UPLOAD);
  20. }
  21. private WebElement getSubmitButton() {
  22. WebElement element = getDriver()
  23. .findElement(By.id(UploadNoSelection.UPLOAD_ID));
  24. WebElement submitButton = element.findElement(By.className("v-button"));
  25. return submitButton;
  26. }
  27. private void assertLogRow(int index, int expentedRowNo,
  28. String expectedValueWithoutRowNo) {
  29. assertEquals(expentedRowNo + ". " + expectedValueWithoutRowNo,
  30. getLogRow(index));
  31. }
  32. }