使用PhantomJS驱动程序时,请添加以下参数:
driver = webdriver.PhantomJS(service_log_path='/var/log/phantomjs/ghostdriver.log')
相关代码,虽然可以选择关闭日志功能,但似乎还不支持:
selenium / webdriver / phantomjs / service.py
class Service(object): """ Object that manages the starting and stopping of PhantomJS / Ghostdriver """ def __init__(self, executable_path, port=0, service_args=None, log_path=None): """ Creates a new instance of the Service :Args: - executable_path : Path to PhantomJS binary - port : Port the service is running on - service_args : A List of other command line options to pass to PhantomJS - log_path: Path for PhantomJS service to log to """ self.port = port self.path = executable_path self.service_args= service_args if self.port == 0: self.port = utils.free_port() if self.service_args is None: self.service_args = [] self.service_args.insert(0, self.path) self.service_args.append("--webdriver=%d" % self.port) if not log_path: log_path = "ghostdriver.log" self._log = open(log_path, 'w')


