Changeset 26114 for main/trunk/greenstone3
- Timestamp:
- 2012-08-16T13:55:30+12:00 (12 years ago)
- Location:
- main/trunk/greenstone3/web/sites/localsite/collect/lucene-jdbm-demo/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/sites/localsite/collect/lucene-jdbm-demo/tests/src/gstests/TestClass.java
r26109 r26114 36 36 public void init() 37 37 { 38 _driver.get( "http://localhost:8487/greenstone3/library");38 _driver.get(System.getProperty("SERVERURL")); 39 39 } 40 40 … … 46 46 public void testHomePage() 47 47 { 48 Assert.assertNotNull( GSTestingUtil.findElementByXPath(_driver, "//div[@id='collectionLinks']/a[@title='Demonstration collection containing a few books from the Humanitarian and Development Libraries. Uses Lucene and JDBM.']"));48 Assert.assertNotNull("The Demo Collection is not available", GSTestingUtil.findElementByXPath(_driver, "//div[@id='collectionLinks']/a[descendant::text()='Demo Collection']")); 49 49 } 50 50 … … 57 57 WebElement demoTitleElem = GSTestingUtil.findElementByXPath(_driver, "//div[@id='titlearea']/h2"); 58 58 String title = demoTitleElem.getText(); 59 Assert.assertTrue( title.equals("Demo Collection"));59 Assert.assertTrue("The title is incorrect", title.equals("Demo Collection")); 60 60 61 61 //Check we have four browsing classifiers 62 62 List<WebElement> classifierLinks = GSTestingUtil.findElementsByXPath(_driver, "//ul[@id='gs-nav']/li"); 63 Assert.assertEquals( classifierLinks.size(), NUMBER_OF_CLASSIFIERS);63 Assert.assertEquals("There should be " + NUMBER_OF_CLASSIFIERS + " classifiers but there were " + classifierLinks.size(), classifierLinks.size(), NUMBER_OF_CLASSIFIERS); 64 64 65 65 //Check we have 3 search types 66 66 List<WebElement> searchTypes = GSTestingUtil.findElementsByXPath(_driver, "//div[@id='quicksearcharea']/ul/li"); 67 Assert.assertEquals( searchTypes.size(), NUMBER_OF_SEARCH_TYPES);67 Assert.assertEquals("There should be " + NUMBER_OF_SEARCH_TYPES + " search types but there were " + searchTypes.size(), searchTypes.size(), NUMBER_OF_SEARCH_TYPES); 68 68 69 69 //Check we have 5 search indexes 70 70 List<WebElement> searchIndexes = GSTestingUtil.findElementsByXPath(_driver, "//div[@id='quicksearcharea']/form/span[@class='textselect']/select/option"); 71 Assert.assertEquals( searchIndexes.size(), NUMBER_OF_SEARCH_INDEXES);71 Assert.assertEquals("There should be " + NUMBER_OF_SEARCH_INDEXES + " search indexes but there were " + searchIndexes.size(), searchIndexes.size(), NUMBER_OF_SEARCH_INDEXES); 72 72 } 73 73 … … 82 82 //Check that we have 11 documents 83 83 List<WebElement> documents = GSTestingUtil.findElementsByXPath(_driver, "//table[@id='classifiernodelist']/tbody/tr"); 84 Assert.assertEquals( documents.size(), TITLE_CLASSIFIER_SIZE);84 Assert.assertEquals("There should be " + TITLE_CLASSIFIER_SIZE + " documents in the titles classifier but there were " + documents.size(), documents.size(), TITLE_CLASSIFIER_SIZE); 85 85 } 86 86 … … 95 95 //Check that we have 7 subjects 96 96 List<WebElement> subjectElems = GSTestingUtil.findElementsByXPath(_driver, "//table[@id='classifiernodelist']/tbody/tr"); 97 Assert.assertEquals( subjectElems.size(), SUBJECT_CLASSIFIER_SIZE);97 Assert.assertEquals("There should be " + SUBJECT_CLASSIFIER_SIZE + " documents in the subjects classifier but there were " + subjectElems.size(), subjectElems.size(), SUBJECT_CLASSIFIER_SIZE); 98 98 99 99 //Get all of the subject expand images … … 107 107 String sectionNumber = randomSubject.getAttribute("id").substring(6); 108 108 GSTestingUtil.waitForXPath(_driver, "//table[@id='div" + sectionNumber + "']"); 109 Assert.assertNotNull( GSTestingUtil.findElementByXPath(_driver, "//table[@id='div" + sectionNumber + "']"));109 Assert.assertNotNull("The subjects classifier did not open correctly", GSTestingUtil.findElementByXPath(_driver, "//table[@id='div" + sectionNumber + "']")); 110 110 } 111 111 … … 120 120 //Check that we have 5 organisations 121 121 List<WebElement> orgElems = GSTestingUtil.findElementsByXPath(_driver, "//table[@id='classifiernodelist']/tbody/tr"); 122 Assert.assertEquals( orgElems.size(), ORGANISATIONS_CLASSIFIER_SIZE);122 Assert.assertEquals("There should be " + ORGANISATIONS_CLASSIFIER_SIZE + " documents in the organisations classifier but there were " + orgElems.size(), orgElems.size(), ORGANISATIONS_CLASSIFIER_SIZE); 123 123 124 124 //Get all of the subject expand images … … 132 132 String sectionNumber = randomOrganisation.getAttribute("id").substring(6); 133 133 GSTestingUtil.waitForXPath(_driver, "//table[@id='div" + sectionNumber + "']"); 134 Assert.assertNotNull( GSTestingUtil.findElementByXPath(_driver, "//table[@id='div" + sectionNumber + "']"));134 Assert.assertNotNull("The organisations classifier did not open correctly", GSTestingUtil.findElementByXPath(_driver, "//table[@id='div" + sectionNumber + "']")); 135 135 } 136 136 … … 152 152 //Check the number of results on the page 153 153 List<WebElement> results = GSTestingUtil.findElementsByXPath(_driver, "//table[@id='resultsTable']/tbody/tr"); 154 Assert.assertEquals( results.size(), HITS_PER_PAGE);154 Assert.assertEquals("The number of results on the page should have been " + HITS_PER_PAGE + " but it was " + results.size(), results.size(), HITS_PER_PAGE); 155 155 156 156 //Check the term info has the correct values 157 157 WebElement termInfo = GSTestingUtil.findElementByXPath(_driver, "//p[@class='termList']/span[@class='termInfo']"); 158 Assert.assertTrue( termInfo.getText().equals("snails occurs " + SNAILS_OCCURENCE_COUNT + " times in " + SNAILS_RESULT_COUNT + " sections"));158 Assert.assertTrue("The term information was incorrect, it should have been \"" + "snails occurs " + SNAILS_OCCURENCE_COUNT + " times in " + SNAILS_RESULT_COUNT + " sections" + "\" but was \"" + termInfo.getText() + "\"", termInfo.getText().equals("snails occurs " + SNAILS_OCCURENCE_COUNT + " times in " + SNAILS_RESULT_COUNT + " sections")); 159 159 160 160 //Check the search results status bar 161 161 WebElement searchStatus = GSTestingUtil.findElementByXPath(_driver, "//td[@id='searchResultsStatusBar']"); 162 Assert.assertTrue( searchStatus.getText().equals("Displaying 1 to " + HITS_PER_PAGE + " of " + SNAILS_RESULT_COUNT + " sections"));162 Assert.assertTrue("The search status was incorrect, it should have been \"" + "Displaying 1 to " + HITS_PER_PAGE + " of " + SNAILS_RESULT_COUNT + " sections" + "\" but it was \"" + searchStatus.getText() + "\"", searchStatus.getText().equals("Displaying 1 to " + HITS_PER_PAGE + " of " + SNAILS_RESULT_COUNT + " sections")); 163 163 164 164 //Click the next button … … 168 168 //Check the search results status bar on the new page 169 169 searchStatus = GSTestingUtil.findElementByXPath(_driver, "//td[@id='searchResultsStatusBar']"); 170 Assert.assertTrue( searchStatus.getText().equals("Displaying " + (HITS_PER_PAGE + 1) + " to " + (HITS_PER_PAGE * 2) + " of " + SNAILS_RESULT_COUNT + " sections"));170 Assert.assertTrue("The search status was incorrect, it should have been \"" + "Displaying " + (HITS_PER_PAGE + 1) + " to " + (HITS_PER_PAGE * 2) + " of " + SNAILS_RESULT_COUNT + " sections" + "\" but it was \"" + searchStatus.getText() + "\"", searchStatus.getText().equals("Displaying " + (HITS_PER_PAGE + 1) + " to " + (HITS_PER_PAGE * 2) + " of " + SNAILS_RESULT_COUNT + " sections")); 171 171 172 172 //Click the previous button … … 179 179 180 180 //Generate a search that will fail 181 String randomSearchTerm = GSTestingUtil.generateRandomString(20); 182 181 183 quickSearchInput = GSTestingUtil.findElementByXPath(_driver, "//div[@id='quicksearcharea']//input[@name='s1.query']"); 182 184 quickSearchInput.clear(); 183 quickSearchInput.sendKeys( GSTestingUtil.generateRandomString(20));185 quickSearchInput.sendKeys(randomSearchTerm); 184 186 quickSearchSubmitButton = GSTestingUtil.findElementByXPath(_driver, "//input[@id='quickSearchSubmitButton']"); 185 187 quickSearchSubmitButton.click(); … … 187 189 //Make sure that no documents match 188 190 WebElement contentElem = GSTestingUtil.findElementByXPath(_driver, "//div[@id='gs_content']"); 189 Assert.assertTrue( contentElem.getText().equals("No documents matched the query."));191 Assert.assertTrue("No results should have been found for \"" + randomSearchTerm, contentElem.getText().equals("No documents matched the query.")); 190 192 } 191 193 … … 201 203 //Make sure we are logged in correctly 202 204 WebElement userListTable = GSTestingUtil.findElementByXPath(_driver, "//table[@id='userListTable']"); 203 Assert.assertNotNull( userListTable);205 Assert.assertNotNull("Administrator failed to log in", userListTable); 204 206 205 207 //Go to the add new user page … … 241 243 { 242 244 found = true; 243 Assert.assertTrue( columns.get(1).getText().equals("enabled"));244 Assert.assertTrue( columns.get(2).getText().equals("TestGroup"));245 Assert.assertTrue( columns.get(3).getText().equals("A user added for testing purposes"));246 Assert.assertTrue( columns.get(4).getText().equals(randomUsername + "@testusername.co.nz"));245 Assert.assertTrue("The new user enabled status was incorrect", columns.get(1).getText().equals("enabled")); 246 Assert.assertTrue("The new user group was incorrect", columns.get(2).getText().equals("TestGroup")); 247 Assert.assertTrue("The new user comment was incorrect", columns.get(3).getText().equals("A user added for testing purposes")); 248 Assert.assertTrue("The new user email was incorrect", columns.get(4).getText().equals(randomUsername + "@testusername.co.nz")); 247 249 } 248 250 } 249 Assert.assertTrue( found);251 Assert.assertTrue("The new user was not found", found); 250 252 251 253 //Log in as the new user … … 255 257 //Check the log in worked 256 258 WebElement menuButton = GSTestingUtil.findElementByXPath(_driver, "//li[@id='userMenuButton']/a"); 257 Assert.assertTrue( menuButton.getText().equals(randomUsername));259 Assert.assertTrue("The new user was not able to log in correctly", menuButton.getText().equals(randomUsername)); 258 260 259 261 //Go to the home page … … 310 312 //Check the cover image is loaded 311 313 WebElement coverImage = GSTestingUtil.findElementByXPath(_driver, "//div[@id='coverImage']/img"); 312 Assert.assertTrue( GSTestingUtil.isImageLoaded(_driver, coverImage));314 Assert.assertTrue("The cover image of the document did not load correctly", GSTestingUtil.isImageLoaded(_driver, coverImage)); 313 315 } 314 316
Note:
See TracChangeset
for help on using the changeset viewer.