Class DynastiesTester


  • public class DynastiesTester
    extends java.lang.Object
    Class used to test the scraping of dynasties names and Wikipedia page URLs
    Author:
    Matteo Collica, Sara Lazzaroni
    See Also:
    Dynasty, Tester
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.HashMap<java.lang.String,​java.lang.String> expectedDynasties  
      private static java.util.HashMap<java.lang.String,​java.lang.String> scrapedDynasties  
      private static org.openqa.selenium.WebDriver webDriver  
    • Constructor Summary

      Constructors 
      Constructor Description
      DynastiesTester()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean doTest()
      Compare the scraped dynasties names and URLs with the expected ones
      static java.util.HashMap<java.lang.String,​java.lang.String> getExpectedDynasties()  
      static java.util.HashMap<java.lang.String,​java.lang.String> getScrapedDynasties()  
      static void initialize()
      Initialize the WebDriver needed to scrape data from the Wikipedia page of Roman Emperors and obtain the dynasties names and Wikipedia page URLs to be compared with the expected ones
      static void initialize​(org.openqa.selenium.WebDriver webDriver)
      Obtain the dynasties names and Wikipedia page URLs to be compared with the expected ones
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • webDriver

        private static org.openqa.selenium.WebDriver webDriver
      • expectedDynasties

        private static java.util.HashMap<java.lang.String,​java.lang.String> expectedDynasties
      • scrapedDynasties

        private static java.util.HashMap<java.lang.String,​java.lang.String> scrapedDynasties
    • Constructor Detail

      • DynastiesTester

        public DynastiesTester()
    • Method Detail

      • initialize

        public static void initialize()
                               throws NoSupportedBrowsersException,
                                      UnsupportedOsException
        Initialize the WebDriver needed to scrape data from the Wikipedia page of Roman Emperors and obtain the dynasties names and Wikipedia page URLs to be compared with the expected ones
        Throws:
        NoSupportedBrowsersException - if there are no supported browsers installed in user's Operating System
        UnsupportedOsException - if the user's Operating System isn't supported (not a Windows, macOS or Unix-based one)
      • initialize

        public static void initialize​(org.openqa.selenium.WebDriver webDriver)
        Obtain the dynasties names and Wikipedia page URLs to be compared with the expected ones
        Parameters:
        webDriver - the WebDriver needed to scrape data from the Wikipedia page
      • doTest

        public static boolean doTest()
        Compare the scraped dynasties names and URLs with the expected ones
        Returns:
        true if the test was completed successfully, false otherwise
      • getScrapedDynasties

        public static java.util.HashMap<java.lang.String,​java.lang.String> getScrapedDynasties()
        Returns:
        the HashMap of scraped dynasties (where the key is the Wikipedia page URL and the value is the dynasty name)
      • getExpectedDynasties

        public static java.util.HashMap<java.lang.String,​java.lang.String> getExpectedDynasties()
        Returns:
        the HashMap of expected dynasties (where the key is the Wikipedia page URL and the value is the dynasty name)