Changeset 32671 for main/trunk/greenstone3/web/sites/localsite/collect
- Timestamp:
- 2018-12-12T19:03:36+13:00 (5 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
r26116 r32671 15 15 public class TestClass 16 16 { 17 /*static { 18 System.setProperty("webdriver.gecko.driver", "/Scratch/ak19/gs3-svn-13Sep2018/ext/testing/geckodriver"); 19 }*/ 20 17 21 //TODO: Do these dynamically 18 22 private static final int NUMBER_OF_CLASSIFIERS = 4; … … 21 25 22 26 //TODO: Turn these into a list 23 private static final int TITLE_CLASSIFIER_SIZE = 11;27 private static final int FIRST_TITLE_CLASSIFIER_SIZE = 1; // total docs under title classifier 11, but now in alphabetically placed into buckets 24 28 private static final int SUBJECT_CLASSIFIER_SIZE = 7; 25 private static final int ORGANISATIONS_CLASSIFIER_SIZE = 5;29 private static final int ORGANISATIONS_CLASSIFIER_SIZE = 4; // used to be 5 26 30 27 31 private static final int HITS_PER_PAGE = 20; … … 36 40 public void init() 37 41 { 42 //https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr 43 //if you didn't update the Path system variable to add the full directory path to the executable as above mentioned then doing this directly through code 44 //System.setProperty("webdriver.gecko.driver", "/Scratch/ak19/gs3-svn-13Sep2018/ext/testing/geckodriver"); 45 38 46 _driver.get(System.getProperty("SERVERURL")); 47 39 48 } 40 49 … … 46 55 public void testHomePage() 47 56 { 48 Assert.assertNotNull("The Demo Collection is not available", GSTestingUtil.findElementByXPath(_driver, "//div[@id='collectionLinks']/a[descendant::text()='Demo Collection']")); 57 //Assert.assertNotNull("The Demo Collection is not available", GSTestingUtil.findElementByXPath(_driver, "//div[@id='collectionLinks']/a[descendant::text()='Demo Collection']")); 58 // https://stackoverflow.com/questions/1604471/how-can-i-find-an-element-by-css-class-with-xpath 59 //Assert.assertNotNull("The Demo Collection is not available", GSTestingUtil.findElementByXPath(_driver, "//div[contains(concat(' ', normalize-space(@class), ' '), 'collectionLinkText')]/a[descendant::text()='Demo Collection']")); 60 61 // Works. Why? 62 //Assert.assertNotNull("The Demo Collection is not available", GSTestingUtil.findElementsByXPath(_driver, "//div[contains(concat(' ', normalize-space(@class), ' '), 'collectionLinkText')]/a[descendant::text()='Demo Collection']")); 63 64 Assert.assertNotNull("The Demo Collection is not available", GSTestingUtil.findElementByXPath(_driver, "//div[contains(concat(' ', normalize-space(@class), ' '), 'collectionLinkText')][descendant::text()='Demo Collection']")); 65 66 //Assert.assertNotNull("The Demo Collection is not available", GSTestingUtil.findElementByXPath(_driver, "/")); 67 49 68 } 50 69 … … 81 100 82 101 //Check that we have 11 documents 102 // Check we have 1 document on the first page of the titles classifier 103 // In the past, all the 11 docs were on the first page. But now they are placed 104 // alphabetically into buckets 83 105 List<WebElement> documents = GSTestingUtil.findElementsByXPath(_driver, "//table[@id='classifiernodelist']/tbody/tr"); 84 Assert.assertEquals("There should be " + TITLE_CLASSIFIER_SIZE + " documents in the titles classifier but there were " + documents.size(), documents.size(), TITLE_CLASSIFIER_SIZE);106 Assert.assertEquals("There should be " + FIRST_TITLE_CLASSIFIER_SIZE + " document(s) in the titles classifier but there were " + documents.size(), FIRST_TITLE_CLASSIFIER_SIZE, documents.size()); 85 107 } 86 108 … … 120 142 //Check that we have 5 organisations 121 143 List<WebElement> orgElems = GSTestingUtil.findElementsByXPath(_driver, "//table[@id='classifiernodelist']/tbody/tr"); 122 Assert.assertEquals("There should be " + ORGANISATIONS_CLASSIFIER_SIZE + " documents in the organisations classifier but there were " + orgElems.size(), orgElems.size(), ORGANISATIONS_CLASSIFIER_SIZE);144 Assert.assertEquals("There should be " + ORGANISATIONS_CLASSIFIER_SIZE + " documents in the organisations classifier but there were " + orgElems.size(), ORGANISATIONS_CLASSIFIER_SIZE, orgElems.size()); 123 145 124 146 //Get all of the subject expand images … … 149 171 //Check the number of results on the page 150 172 List<WebElement> results = GSTestingUtil.findElementsByXPath(_driver, "//table[@id='resultsTable']/tbody/tr"); 151 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);173 Assert.assertEquals("The number of results on the page should have been " + HITS_PER_PAGE + " but it was " + results.size(), HITS_PER_PAGE, results.size()); 152 174 153 175 //Check the term info has the correct values 154 176 WebElement termInfo = GSTestingUtil.findElementByXPath(_driver, "//p[@class='termList']/span[@class='termInfo']"); 155 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(" snailsoccurs " + SNAILS_OCCURENCE_COUNT + " times in " + SNAILS_RESULT_COUNT + " sections"));177 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")); 156 178 157 179 //Check the search results status bar … … 181 203 182 204 //Make sure that no documents match 183 WebElement contentElem = GSTestingUtil.findElementByXPath(_driver, "//div[@id='gs_content'] ");184 Assert.assertTrue("No results should have been found for \"" + randomSearchTerm , contentElem.getText().equals("No documents matchedthe query."));205 WebElement contentElem = GSTestingUtil.findElementByXPath(_driver, "//div[@id='gs_content']/div[@id='matchdocs']"); 206 Assert.assertTrue("No results should have been found for \"" + randomSearchTerm + "\"", contentElem.getText().equals("No sections match the query.")); 185 207 } 186 208 … … 311 333 public static void destroy() 312 334 { 313 335 _driver.quit(); 314 336 } 315 337 }
Note:
See TracChangeset
for help on using the changeset viewer.