Selenium webdriver 使用现有的Chrome浏览器和使用RobotFramework的远程调试端口

Selenium webdriver 使用现有的Chrome浏览器和使用RobotFramework的远程调试端口,selenium-webdriver,selenium-chromedriver,robotframework,Selenium Webdriver,Selenium Chromedriver,Robotframework,我正在尝试使用RobotFramework(SeleniumLibrary)使用现有的google chrome实例。我正在像这样启动chrome实例 chrome.exe --remote-debugging-port=9289 --user-data-dir="D:\gcdata" 这是我在robotframework中的代码 ${options}= Evaluat sys.modules['selenium.webdriver'].ChromeOptions() sys,se

我正在尝试使用RobotFramework(SeleniumLibrary)使用现有的google chrome实例。我正在像这样启动chrome实例

chrome.exe --remote-debugging-port=9289 --user-data-dir="D:\gcdata"
这是我在robotframework中的代码

${options}= Evaluat      sys.modules['selenium.webdriver'].ChromeOptions()  sys,selenium.webdriver  
${prefs}=       Create Dictionary   debuggerAddress     127.0.0.1:9289
Call Method    ${options}           add_experimental_option    prefs    ${prefs}
Create WebDriver    Chrome  chrome_options=${options}       

当我运行RobotFramework代码时,它会调用一个新的浏览器。这里有谁能帮我告诉我出了什么问题以及如何修复它。

使用最新版本的Python Selenium模块、Chrome和ChromeDriver,以下机器人脚本将连接到已经运行的Chrome,该Chrome已开始使用:

chrome.exe --remote-debugging-port=9289 --user-data-dir="C:\temp\gdata"
chrome\u调试器.机器人

*** Settings ***
Library    SeleniumLibrary  
Library    Collections      

*** Test Cases ***
TC

    ${ChromeOptions}=     Evaluate      sys.modules['selenium.webdriver'].ChromeOptions()  sys,selenium.webdriver 

    # Method debugger_address is not callable so convert to Capabilities Dictionary and set it manually
    ${ChromeCapabilities}=     Call Method     ${ChromeOptions}    to_capabilities
    Set To Dictionary    ${ChromeCapabilities["goog:chromeOptions"]}    debuggerAddress    127.0.0.1:9289

    # Instead of using the Chrome Options use Capabilities.
    Create WebDriver    Chrome    desired_capabilities=${ChromeCapabilities}
    Go To    http://cnn.com
即使
ChromeOptions
class()具有
debugger\u address(self,value)
方法,从Robot框架调用此方法也会返回错误。因此,将
ChromeOptions
类转换为
Capabilities
字典,并手动将其添加到字典中,然后通过
所需的\u Capabilities
参数将其传递给webdriver