def start(self, proxy=None, cookie_db=None, disk_cache_dir=None,
              disk_cache_size=None):
        '''
        Starts chrome/chromium process.

        Args:
            proxy: http proxy 'host:port' (default None)
            cookie_db: raw bytes of chrome/chromium sqlite3 cookies database,
                which, if supplied, will be written to
                {chrome_user_data_dir}/Default/Cookies before running the
                browser (default None)
            disk_cache_dir: use directory for disk cache. The default location
                is inside `self._home_tmpdir` (default None).
            disk_cache_size: Forces the maximum disk space to be used by the disk
                cache, in bytes. (default None)
        Returns:
            websocket url to chrome window with about:blank loaded
        '''
        # these can raise exceptions
        self._home_tmpdir = tempfile.TemporaryDirectory()
        self._chrome_user_data_dir = os.path.join(
            self._home_tmpdir.name, 'chrome-user-data')
        if cookie_db:
            self._init_cookie_db(cookie_db)
        self._shutdown.clear()

        new_env = os.environ.copy()
        new_env['HOME'] = self._home_tmpdir.name
        chrome_args = [
                self.chrome_exe,
                '--remote-debugging-port=%s' % self.port,
                '--use-mock-keychain', # mac thing
                '--user-data-dir=%s' % self._chrome_user_data_dir,
                '--disable-background-networking',
                '--disable-renderer-backgrounding', '--disable-hang-monitor',
                '--disable-background-timer-throttling', '--mute-audio',
                '--disable-web-sockets',
                '--window-size=1100,900', '--no-default-browser-check',
                '--disable-first-run-ui', '--no-first-run',
                '--homepage=about:blank', '--disable-direct-npapi-requests',
                '--disable-web-security', '--disable-notifications',
                '--disable-extensions', '--disable-save-password-bubble']

        if disk_cache_dir:
            chrome_args.append('--disk-cache-dir=%s' % disk_cache_dir)
        if disk_cache_size:
            chrome_args.append('--disk-cache-size=%s' % disk_cache_size)
        if self.ignore_cert_errors:
            chrome_args.append('--ignore-certificate-errors')
        if proxy:
            chrome_args.append('--proxy-server=%s' % proxy)
        chrome_args.append('about:blank')
        self.logger.info('running: %r', subprocess.list2cmdline(chrome_args))
        # start_new_session - new process group so we can kill the whole group
        self.chrome_process = subprocess.Popen(
                chrome_args, env=new_env, start_new_session=True,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0)
        self._out_reader_thread = threading.Thread(
                target=self._read_stderr_stdout,
                name='ChromeOutReaderThread:%s' % self.port, daemon=True)
        self._out_reader_thread.start()
        self.logger.info('chrome running, pid %s' % self.chrome_process.pid)

        return self._websocket_url()
def start ( self , proxy = None , cookie_db = None , disk_cache_dir = None , disk_cache_size = None ) : self . _home_tmpdir = tempfile . TemporaryDirectory ( ) self . _chrome_user_data_dir = os . path . join ( self . _home_tmpdir . name , 'chrome-user-data' ) if cookie_db : self . _init_cookie_db ( cookie_db ) self . _shutdown . clear ( ) new_env = os . environ . copy ( ) new_env [ 'HOME' ] = self . _home_tmpdir . name chrome_args = [ self . chrome_exe , '--remote-debugging-port=%s' % self . port , '--use-mock-keychain' , '--user-data-dir=%s' % self . _chrome_user_data_dir , '--disable-background-networking' , '--disable-renderer-backgrounding' , '--disable-hang-monitor' , '--disable-background-timer-throttling' , '--mute-audio' , '--disable-web-sockets' , '--window-size=1100,900' , '--no-default-browser-check' , '--disable-first-run-ui' , '--no-first-run' , '--homepage=about:blank' , '--disable-direct-npapi-requests' , '--disable-web-security' , '--disable-notifications' , '--disable-extensions' , '--disable-save-password-bubble' ] if disk_cache_dir : chrome_args . append ( '--disk-cache-dir=%s' % disk_cache_dir ) if disk_cache_size : chrome_args . append ( '--disk-cache-size=%s' % disk_cache_size ) if self . ignore_cert_errors : chrome_args . append ( '--ignore-certificate-errors' ) if proxy : chrome_args . append ( '--proxy-server=%s' % proxy ) chrome_args . append ( 'about:blank' ) self . logger . info ( 'running: %r' , subprocess . list2cmdline ( chrome_args ) ) self . chrome_process = subprocess . Popen ( chrome_args , env = new_env , start_new_session = True , stdout = subprocess . PIPE , stderr = subprocess . PIPE , bufsize = 0 ) self . _out_reader_thread = threading . Thread ( target = self . _read_stderr_stdout , name = 'ChromeOutReaderThread:%s' % self . port , daemon = True ) self . _out_reader_thread . start ( ) self . logger . info ( 'chrome running, pid %s' % self . chrome_process . pid ) return self . _websocket_url ( )
Starts chrome/chromium process.

        Args:
            proxy: http proxy 'host:port' (default None)
            cookie_db: raw bytes of chrome/chromium sqlite3 cookies database,
                which, if supplied, will be written to
                {chrome_user_data_dir}/Default/Cookies before running the
                browser (default None)
            disk_cache_dir: use directory for disk cache. The default location
                is inside `self._home_tmpdir` (default None).
            disk_cache_size: Forces the maximum disk space to be used by the disk
                cache, in bytes. (default None)
        Returns:
            websocket url to chrome window with about:blank loaded