python - selenium.common.exceptions.WebDriverException:消息:无法连接到服务 /usr/bin/safaridriver
问题描述
基本上,在我的 Mac 上,硒不起作用。我的代码是这样的:
from selenium import webdriver
webdriver.Safari('/usr/bin/safaridriver')
这实际上是最基本的 selenium 脚本,但它不起作用......在我的程序运行 30 秒后,我收到此错误:selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /usr/bin/safaridriver
. 我不知道为什么会这样……我的 safari 版本是最新的,(14.0.1),但我一直收到这个错误。谢谢你的帮助!
解决方案
传递给的第一个位置参数webdriver.Safari
不是executable_path
参数,而是port
参数。您必须将路径作为位置参数传递。
webdriver.Safari(executable_path='/usr/bin/safaridriver')
推荐阅读
- angular - 每次 redux 存储刷新时,本地角度状态都会消失
- d3.js - 你将如何在 d3 中的一个节点上显示多个字段?
- java - 从另一个面板上的按钮打开 JFrame 上的 JPanel
- c# - 从子级转换为父级时出现 InvalidCastException
- powerbi - PowerBI - DAX - 基于标准 x 的列的总和
- ionic-framework - ionic v4 中的 ion-button 文本为大写
- apache-spark - Spark 结构化和 Dstream 应用程序正在写入重复项
- c# - 未使用 MVC 解决方案解析的远程主机名
- spring-boot - CompositeMeterRegistry 忽略千分尺过滤器
- https - 骆驼代理配置骆驼-https4