1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.elements;
17
18 import java.io.File;
19 import java.util.List;
20 import org.junit.Test;
21 import org.kuali.rice.testtools.selenium.WebDriverFileResourceAftBase;
22 import org.openqa.selenium.By;
23
24
25
26
27 public class LibraryElementMultiFileUploadAft extends WebDriverFileResourceAftBase {
28
29
30
31
32 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-MultiFileUploadView";
33
34
35 protected List<File> fileUploadList;
36
37 @Override
38 protected String getBookmarkUrl() {
39 return BOOKMARK_URL;
40 }
41
42 @Override
43 protected void navigate() throws Exception {
44 waitAndClickLibraryLink();
45 waitAndClickByLinkText("Elements");
46 waitAndClickByLinkText("Multi-file Upload");
47 }
48
49 protected void testElementMultiFileUpload() throws Exception {
50 fileUploadSetUpforText();
51 fileIngesterByName("files");
52 assertLinked();
53 assertDelete();
54
55 selectByName("exampleShown", "Max Size Multi-file Upload");
56 fileUploadSetUpforPdf();
57 fileIngesterByName("files1");
58 waitForElementVisibleBy(By.linkText("test.pdf"));
59 assertTrue(isTextPresent("9.2 KB"));
60 clickFirstTrashIcon();
61 waitForElementNotPresent(By.linkText("test.pdf"));
62
63 selectByName("exampleShown", "Extra Fields Multi-file Upload");
64 fileUploadSetUpforText();
65 fileIngesterByName("files2");
66 assertLinked();
67 isElementPresentByName("files2[0].detail1");
68 isElementPresentByName("files2[0].detail2");
69 assertDelete();
70
71 selectByName("exampleShown", "File Types Multi-file Upload");
72 fileUploadSetUpforJpg();
73 fileIngesterByName("files3");
74 waitForElementVisibleBy(By.linkText("home.jpg"));
75 clickFirstTrashIcon();
76 waitForElementNotPresent(By.linkText("home.jpg"));
77 }
78
79 private void assertLinked() throws InterruptedException {
80 waitForElementVisibleBy(By.linkText("test.txt"));
81 waitForElementVisibleBy(By.linkText("test1.txt"));
82 }
83
84 private void assertDelete() throws InterruptedException {
85 clickFirstTrashIcon();
86 waitForElementNotPresent(By.linkText("test.txt"));
87
88 clickFirstTrashIcon();
89 waitForElementNotPresent(By.linkText("test1.txt"));
90 }
91
92 private void clickFirstTrashIcon() throws InterruptedException {
93 jGrowl("Click trash icon");
94 waitAndClickByXpath("//div[@id='Demo-MultiFileUploadView']//button[contains(@class,'icon-trash')]");
95 waitAndClickConfirmDeleteYes();
96 }
97
98 private void fileUploadSetUpforText() throws Exception {
99 setUpResourceDir("general", "txt");
100 }
101
102 private void fileUploadSetUpforJpg() throws Exception {
103 setUpResourceDir("general", "jpg");
104 }
105
106 private void fileUploadSetUpforPdf() throws Exception {
107 setUpResourceDir("general", "pdf");
108 }
109
110 @Test
111 public void testElementMultiFileUploadBookmark() throws Exception {
112 testElementMultiFileUpload();
113 passed();
114 }
115
116 @Test
117 public void testElementMultiFileUploadNav() throws Exception {
118 testElementMultiFileUpload();
119 passed();
120 }
121 }