Ignore:
Timestamp:
2018-12-12T19:03:36+13:00 (5 years ago)
Author:
ak19
Message:

Changes necessary to get Sam's basic Selenium tests of the lucene-jdbm-demo collection working again: 1. The change to jquery.min.js is that the first hash character now used to be an at-sign which was deprecated and issued warnings. 2. build.xml now points the Selenium testing java code to the geckodriver, required to run newer firefox which no longer comes with a built-in driver for Selenium. 3. Needed to make changes to the testing code, since XPaths in the XML used to find some elements have changed and also the number of documents in the first page of the Titles classifier, and exact wording of certain search results.

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  
    1515public class TestClass
    1616{
     17    /*static {
     18    System.setProperty("webdriver.gecko.driver", "/Scratch/ak19/gs3-svn-13Sep2018/ext/testing/geckodriver");
     19    }*/
     20   
    1721    //TODO: Do these dynamically
    1822    private static final int NUMBER_OF_CLASSIFIERS = 4;
     
    2125
    2226    //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
    2428    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
    2630
    2731    private static final int HITS_PER_PAGE = 20;
     
    3640    public void init()
    3741    {
     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       
    3846        _driver.get(System.getProperty("SERVERURL"));
     47       
    3948    }
    4049
     
    4655    public void testHomePage()
    4756    {
    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       
    4968    }
    5069
     
    81100
    82101        //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
    83105        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());
    85107    }
    86108
     
    120142        //Check that we have 5 organisations
    121143        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());
    123145
    124146        //Get all of the subject expand images
     
    149171        //Check the number of results on the page
    150172        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());
    152174
    153175        //Check the term info has the correct values
    154176        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("snails occurs " + 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"));
    156178
    157179        //Check the search results status bar
     
    181203
    182204        //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 matched the 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."));
    185207    }
    186208
     
    311333    public static void destroy()
    312334    {
    313         _driver.quit();
     335        _driver.quit();
    314336    }
    315337}
Note: See TracChangeset for help on using the changeset viewer.