def test_har_nofiles(self):

    import os
    har_file_made = False
    config = {"headless": True, "fire_bug": True, "net_export": True}
    myPage = WebPage(localhost, config=config)

    glob_re = "{0}/localhost+20??-??-??+??-??-??.har".format(myPage.har_output)
    
    file_list = glob.glob(glob_re)
    for file_indv in file_list:
      myPage.logger.info(file_indv)
      os.remove(file_indv)

    number_before = len(glob.glob(glob_re))

    try:
      myPage.pageLoad(wait={"type": "CLASS_NAME", "value": "q"})
      har_file_made = myPage.har_file_made
    except Exception:
      myPage.log_fail(Exception)
    finally:
      myPage.quit()
    
    number_after = len(glob.glob(glob_re))
    simple_check = number_after > number_before

    self.assertTrue(simple_check & har_file_made)
  def test_query_author(self):

    success_text = ""

    config = {"headless": True, "fire_bug": False, "net_export": False}

    myPage = WebPage(localhost, config=config)
    myPage.pageLoad(wait={"type": "CLASS_NAME", "value": "q"})

    #myPage.logger.info("waiting...")
    #time.sleep(1)
    #class_identify = "list-of-things"
    #class_identify = "col-sm-5"
    #class_identify = "col-sm-4 col-xs-5 s-top-row-col identifier s-identifier"
    #class_identify = "col-sm-12 results-list  s-results-list list-unstyled s-display-block"
    #class_identify = "sr-only"
    #class_identify = "//*[contains(@class, \"results-list\")]"
    #class_identify = "li.col-sm-12.results-list"
    class_identify = "s-results-title"
    element = myPage.sendQuery(query="Elliott", wait={"type": "CLASS_NAME", "value": class_identify})

    try:
      self.assertTrue("Elliott" in myPage.page_source)
    except Exception:
      myPage.log_fail(Exception)
    finally:
      myPage.quit()
  def test_har_output(self):
     
    config = {"headless": True, "fire_bug": True, "net_export": True}

    myPage = WebPage(localhost, config=config)

    glob_re = "{0}/localhost+20??-??-??+??-??-??.har".format(myPage.har_output)

    number_before = len(glob.glob(glob_re))
    number_after = number_before

    myPage.pageLoad(wait={"type": "CLASS_NAME", "value": "q"})

    myPage.logger.info("Waiting for har output file...")
    timer, timeout = 0, 30
    while number_before == number_after:
      number_after = len(glob.glob(glob_re))
      time.sleep(1)
      timer += 1
      myPage.logger.info("... {0} seconds [{1}]".format(timer, timeout))
 
      # Timeout
      if timer == timeout: break

    myPage.logger.info("Investigating output folder: {0}".format(glob_re))
    try:
      self.assertTrue(number_after > number_before)
    except Exception:
      myPage.log_fail(Exception)
    finally:
      myPage.quit()
  def test_load_page(self):
    """Simple test to ensure a basic load works."""
    myPage = WebPage(localhost)
    myPage.pageLoad()

    try:
      self.assertEqual("Bumblebee discovery", myPage.title)
      self.assertTrue(myPage.load_time > 0)
    except Exception:
      myPage.log_fail(Exception)
    finally:
      myPage.quit()
def run_performance():

  localhost = "http://localhost:80"
  config = {"headless": True,
            "fire_bug": True,
            "net_export": True,
            "net_export_output": HAR_PATH,
           }
  bumblebee = WebPage(localhost, config=config)

  try:
    bumblebee.pageLoad(wait={"type": "CLASS_NAME", "value": "q"})
  except Exception:
    bumblebee.log_fail(Exception)
  finally:
    bumblebee.quit()
Example #6
0
def run_performance():

    localhost = "http://localhost:80"
    config = {
        "headless": True,
        "fire_bug": True,
        "net_export": True,
        "net_export_output": HAR_PATH,
    }
    bumblebee = WebPage(localhost, config=config)

    try:
        bumblebee.pageLoad(wait={"type": "CLASS_NAME", "value": "q"})
    except Exception:
        bumblebee.log_fail(Exception)
    finally:
        bumblebee.quit()
  def test_load_page_config(self):
    """Simple test that all the config parameters parse correctly."""

    config = {
        "headless": True,
        "fire_bug": False,
        "net_export": False,
        "fake_input": False,
        "net_export_output": "{0}/har".format(STRESS_PATH),
        }
    
    myPage = WebPage(localhost, config=config)
    try:
      self.assertTrue("fake_input" not in myPage.config)
    except Exception:
      myPage.log_fail(Exception)
    finally:
      myPage.quit()