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.labs.clientside.stateview;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.WebDriverAftBase;
20  import org.openqa.selenium.By;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class LabsClientSideStateViewAft extends WebDriverAftBase {
26  
27      /**
28       * /kr-krad/labs?viewId=Lab-ClientSideState&pageId=Lab-ClientSideState-Page1
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/labs?viewId=Lab-ClientSideState&pageId=Lab-ClientSideState-Page1";
31  
32      @Override
33      protected void navigate() throws Exception {
34          waitAndClickLinkContainingText("Client Side State Test View");
35      }
36  
37      @Override
38      protected String getBookmarkUrl() {
39          return BOOKMARK_URL;
40      }
41  
42      @Test
43      public void testClientSideStateViewBookmark() throws Exception {
44          testClientSideStateView();
45          passed();
46      }
47  
48      @Test
49      public void testClientSideStateViewNav() throws Exception {
50          testClientSideStateView();
51          passed();
52      }
53  
54      public void testClientSideStateView() throws Exception {
55          waitAndClickButtonByText(SHOW_INACTIVE); // first
56          Thread.sleep(500);
57          waitAndClickButtonByText(SHOW_INACTIVE); // second, first has changed
58  //        waitAndClickByXpath("//section[@data-parent=\"Lab-ClientSideState-Page1\"]/header/div/button[contains(.,'show inactive')]"); // first show inactive
59  //        waitAndClickByXpath("//section[@data-parent=\"Lab-ClientSideState-Page1\"]/header/div/button[contains(.,'show inactive')]"); // the second show inactive is now the only one
60          waitAndClickButtonByText("Refresh - Ajax");
61          Thread.sleep(2000);
62          waitForElementNotPresent(By.xpath("//section[@data-parent=\"Lab-ClientSideState-Page1\"][1]/header/div/button[contains(.,'" + SHOW_INACTIVE + "')]")); // first inactive, still Hide inactive
63          waitForElementPresent(By.xpath("//section[@data-parent=\"Lab-ClientSideState-Page1\"]/header/div/button[contains(.,'Hide inactive')]")); // first inactive is Hide inactive
64          waitAndClickButtonByText("Refresh - Non-Ajax");
65          Thread.sleep(2000);
66          waitForElementNotPresent(By.xpath("//section[@data-parent=\"Lab-ClientSideState-Page1\"][1]/header/div/button[contains(.,'" + SHOW_INACTIVE + "')]")); // first show inactive, still Hide inactive
67          waitForElementPresent(By.xpath("//section[@data-parent=\"Lab-ClientSideState-Page1\"]/header/div/button[contains(.,'Hide inactive')]")); // first inactive is Hide inactive
68          assertFalse(isElementPresent(By.xpath("//section[@data-parent=\"Lab-ClientSideState-Page1\"][2]/header/div/button[contains(.,'" + SHOW_INACTIVE + "')]"))); // second show inactive, still Hide inactive
69      }
70  }