要指定Selenium使用Firefox浏览器的端口,你可以使用webdriver.firefox.port属性。下面是一个示例代码:

from selenium import webdriver

# 设置Firefox浏览器的端口
webdriver.FirefoxOptions().add_argument("--webdriver-port=8001")

# 启动Firefox浏览器
driver = webdriver.Firefox()

# 打开网页并进行操作
driver.get("https://www.example.com")

在这个示例中,我们将Firefox浏览器的端口设置为8001,然后启动了Firefox浏览器,并打开了一个网页进行操作。你可以根据自己的需求更改端口号。

selenium指定火狐浏览器的端口

原文地址: https://www.cveoy.top/t/topic/hLpK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录