Ubuntu 18.04+selenium 错误 can't kill an exited process

如以下错误:

1.selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

2.或selenium.common.exceptions.WebDriverException:Message: Process unexpectedly closed with status:1

selenium出现这个错误是因为脚本在root用户下运行导致,若你用的是firefox,firefox geckodriver的log中出现以下错误提示:
Running Firefox as root in a regular user's session is not supported. ($HOME is /root which is owned by www.)

使用chrome也有类似报错;

明确原因是Firefox不支持root用户;

解决方案:
1.新建新用户
2.在新用户下运行相应的脚本
3.如果有文件的读写权限问题,请赋予相应的权限

你可能感兴趣的:(Ubuntu 18.04+selenium 错误 can't kill an exited process)