这是Python中selenium webdriver边缘到调试器地址的正确逻辑吗?

问题描述 投票:0回答:1

我正在导入正确的模块,但我不断收到错误。我认为上面是如何使用调试器地址打开边缘的方法。下面的说法正确吗?我拿出了我的webriver路径和调试器地址,但是逻辑是吧?

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options

ser = Service("")

op = webdriver.EdgeOptions()

op.add_experimental_option("debuggerAddress", "")

bezinga = webdriver.Edge(service = ser, options = op)

print('edge connected')
selenium-webdriver
1个回答
0
投票

首先,删除与 Edge 无关的不必要的导入,如下所示:

from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options

然后,初始化适当的对象并分配调试器地址:

edge_service = Service("<your_edge_driver_path>")
debugger_address = "<your_debugger_address>"

edge_options = Options()
edge_options.add_experimental_option("debuggerAddress", debugger_address)

bezinga = webdriver.Edge(service=edge_service, options=edge_options)

print('Microsoft Edge Connected')
© www.soinside.com 2019 - 2024. All rights reserved.