001 package edu.samplu.krad.demo.uif.library; 002 003 import com.thoughtworks.selenium.SeleneseTestBase; 004 import org.junit.Test; 005 import org.openqa.selenium.By; 006 import org.openqa.selenium.WebElement; 007 008 /** 009 * @author Kuali Rice Team (rice.collab@kuali.org) 010 */ 011 public class DemoLibraryFieldsLinkSmokeTest extends DemoLibraryBase { 012 013 /** 014 * /kr-krad/kradsampleapp?viewId=Demo-LinkField-View&methodToCall=start 015 */ 016 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-LinkField-View&methodToCall=start"; 017 018 @Override 019 public String getBookmarkUrl() { 020 return BOOKMARK_URL; 021 } 022 023 @Override 024 protected void navigate() throws Exception { 025 navigateToLibraryDemo("Fields", "Link Field"); 026 } 027 028 protected void testLinkFieldDefault() throws Exception { 029 WebElement exampleDiv = navigateToExample("Demo-LinkField-Example1"); 030 WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv); 031 032 String fieldId = field.getAttribute("id"); 033 034 assertIsVisible("#" + fieldId); 035 waitAndClickByLinkText(field.getText()); 036 037 Thread.sleep(2000); 038 039 assertTextPresent("Kuali Foundation"); 040 041 driver.navigate().back(); 042 } 043 044 protected void testLinkFieldCustomTarget() throws Exception { 045 WebElement exampleDiv = navigateToExample("Demo-LinkField-Example2"); 046 WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv); 047 048 String fieldId = field.getAttribute("id"); 049 050 assertIsVisible("#" + fieldId); 051 waitAndClickByLinkText(field.getText()); 052 053 Thread.sleep(2000); 054 055 switchToWindow("Kuali Foundation"); 056 057 SeleneseTestBase.assertEquals("http://www.kuali.org/", driver.getCurrentUrl()); 058 driver.close(); 059 060 switchToWindow("Kuali"); 061 } 062 063 protected void testLinkFieldLightbox() throws Exception { 064 WebElement exampleDiv = navigateToExample("Demo-LinkField-Example3"); 065 WebElement field = findElement(By.cssSelector(".uif-link"), exampleDiv); 066 067 String fieldId = field.getAttribute("id"); 068 069 assertIsVisible("#" + fieldId); 070 waitAndClickByLinkText(field.getText()); 071 072 WebElement lightboxIFrame = driver.findElement(By.cssSelector(".fancybox-iframe")); 073 if (!lightboxIFrame.getAttribute("src").contains("www.kuali.org")) { 074 fail("Lightbox did not appear"); 075 } 076 } 077 078 protected void testLinkFieldExamples() throws Exception { 079 testLinkFieldDefault(); 080 testLinkFieldCustomTarget(); 081 testLinkFieldLightbox(); 082 } 083 084 @Test 085 public void testLinkFieldExamplesBookmark() throws Exception { 086 testLinkFieldExamples(); 087 passed(); 088 } 089 090 @Test 091 public void testLinkFieldExamplesNav() throws Exception { 092 testLinkFieldExamples(); 093 passed(); 094 } 095 096 @Test 097 public void testLinkFieldDefaultBookmark() throws Exception { 098 testLinkFieldDefault(); 099 passed(); 100 } 101 102 @Test 103 public void testLinkFieldDefaultNav() throws Exception { 104 testLinkFieldDefault(); 105 passed(); 106 } 107 108 @Test 109 public void testLinkFieldCustomTargetBookmark() throws Exception { 110 testLinkFieldCustomTarget(); 111 passed(); 112 } 113 114 @Test 115 public void testLinkFieldCustomTargetNav() throws Exception { 116 testLinkFieldCustomTarget(); 117 passed(); 118 } 119 120 @Test 121 public void testLinkFieldLightboxBookmark() throws Exception { 122 testLinkFieldLightbox(); 123 passed(); 124 } 125 126 @Test 127 public void testLinkFieldLightboxNav() throws Exception { 128 testLinkFieldLightbox(); 129 passed(); 130 } 131 }