View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.demo.uif.library.fields;
17  
18  import com.thoughtworks.selenium.SeleneseTestBase;
19  import org.junit.Test;
20  import org.kuali.rice.krad.demo.uif.library.LibraryBase;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.WebElement;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class LibraryFieldsLinkAft extends LibraryBase {
28  
29      /**
30       * /kr-krad/kradsampleapp?viewId=Demo-LinkFieldView&methodToCall=start
31       */
32      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-LinkFieldView&methodToCall=start";
33  
34      @Override
35      public String getBookmarkUrl() {
36          return BOOKMARK_URL;
37      }
38  
39      @Override
40      protected void navigate() throws Exception {
41          navigateToLibraryDemo("Fields", "Link Field");
42      }
43  
44      protected void testLinkFieldDefault() throws Exception {
45          WebElement exampleDiv = navigateToExample("Demo-LinkField-Example1");
46          WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv);
47  
48          String fieldId = field.getAttribute("id");
49  
50          assertIsVisible("#" + fieldId);
51          waitAndClickByLinkText(field.getText());
52  
53          Thread.sleep(2000);
54  
55          assertTextPresent("Kuali Foundation");
56  
57          driver.navigate().back();
58      }
59  
60      protected void testLinkFieldCustomTarget() throws Exception {
61          WebElement exampleDiv = navigateToExample("Demo-LinkField-Example2");
62          WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv);
63  
64          String fieldId = field.getAttribute("id");
65  
66          assertIsVisible("#" + fieldId);
67          waitAndClickByLinkText(field.getText());
68  
69          Thread.sleep(2000);
70  
71          switchToWindow("Kuali Foundation");
72  
73          SeleneseTestBase.assertEquals("http://www.kuali.org/", driver.getCurrentUrl());
74          driver.close();
75  
76          switchToWindow("Kuali");
77      }
78  
79      protected void testLinkFieldLightbox() throws Exception {
80          WebElement exampleDiv = navigateToExample("Demo-LinkField-Example3");
81          WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv);
82  
83          String fieldId = field.getAttribute("id");
84  
85          assertIsVisible("#" + fieldId);
86          waitAndClickByLinkText(field.getText());
87  
88          waitForProgressLoading();
89          waitForElementVisibleBy(By.xpath("//iframe[@src='http://www.kuali.org']"));
90      }
91  
92      protected void testLinkFieldExamples() throws Exception {
93          testLinkFieldDefault();
94          testLinkFieldCustomTarget();
95          testLinkFieldLightbox();
96      }
97  
98      @Test
99      public void testLinkFieldExamplesBookmark() throws Exception {
100         testLinkFieldExamples();
101         passed();
102     }
103 
104     @Test
105     public void testLinkFieldExamplesNav() throws Exception {
106         testLinkFieldExamples();
107         passed();
108     }
109 
110     @Test
111     public void testLinkFieldDefaultBookmark() throws Exception {
112         testLinkFieldDefault();
113         passed();
114     }
115 
116     @Test
117     public void testLinkFieldDefaultNav() throws Exception {
118         testLinkFieldDefault();
119         passed();
120     }
121 
122     @Test
123     public void testLinkFieldCustomTargetBookmark() throws Exception {
124         testLinkFieldCustomTarget();
125         passed();
126     }
127 
128     @Test
129     public void testLinkFieldCustomTargetNav() throws Exception {
130         testLinkFieldCustomTarget();
131         passed();
132     }
133 
134     @Test
135     public void testLinkFieldLightboxBookmark() throws Exception {
136         testLinkFieldLightbox();
137         passed();
138     }
139 
140     @Test
141     public void testLinkFieldLightboxNav() throws Exception {
142         testLinkFieldLightbox();
143         passed();
144     }
145 }