def run(self, input_files, url=None, verbose=0):
        """
        run the headless browser with given input
        if url given, the proc will only run hlb with given url and ignore input_list.
        :param url:
        :param input_files: the name of the file in "index url" format. i.e.
                1, www.facebook.com
                1, www.google.com
                ...
        :param verbose:
        :return:
        """
        if not url and not input_files:
            logging.warning("No input file")
            return {"error": "no inputs"}

        results = {}

        self.open_virtual_display()
        if verbose > 0:
            log_file = sys.stdout
        else:
            log_file = None

        # set up firefox driver 
        self.binary = FirefoxBinary(os.path.join(self.cur_path, 'firefox/firefox'), log_file=log_file)
        self.profile = self.setup_profile()
        self.driver = webdriver.Firefox(firefox_profile=self.profile, firefox_binary=self.binary, timeout=60)
        self.driver.set_page_load_timeout(60)

        isfile = False
        if url:
            host, path = self.divide_url(url)
            results[url] = self.get(host, path)
        else:
            isfile = True
            for input_file in input_files.items():
                logging.info("Testing input file %s..." % (input_file[0]))
                self.run_file(input_file, results)

        # foctor_core will quit the driver by itself so we only quit the driver when we don't use foctor core
        if not isfile:
            logging.info("Quit driver")
            self.driver.quit()
            self.close_virtual_display()

        logging.debug("Deleting har folder")
        shutil.rmtree(os.path.join(self.cur_path, 'har'))
        return results
def run ( self , input_files , url = None , verbose = 0 ) : if not url and not input_files : logging . warning ( "No input file" ) return { "error" : "no inputs" } results = { } self . open_virtual_display ( ) if verbose > 0 : log_file = sys . stdout else : log_file = None self . binary = FirefoxBinary ( os . path . join ( self . cur_path , 'firefox/firefox' ) , log_file = log_file ) self . profile = self . setup_profile ( ) self . driver = webdriver . Firefox ( firefox_profile = self . profile , firefox_binary = self . binary , timeout = 60 ) self . driver . set_page_load_timeout ( 60 ) isfile = False if url : host , path = self . divide_url ( url ) results [ url ] = self . get ( host , path ) else : isfile = True for input_file in input_files . items ( ) : logging . info ( "Testing input file %s..." % ( input_file [ 0 ] ) ) self . run_file ( input_file , results ) if not isfile : logging . info ( "Quit driver" ) self . driver . quit ( ) self . close_virtual_display ( ) logging . debug ( "Deleting har folder" ) shutil . rmtree ( os . path . join ( self . cur_path , 'har' ) ) return results
run the headless browser with given input
        if url given, the proc will only run hlb with given url and ignore input_list.
        :param url:
        :param input_files: the name of the file in "index url" format. i.e.
                1, www.facebook.com
                1, www.google.com
                ...
        :param verbose:
        :return: