(Selenium ruby​​)如何添加debuggerAddress实验选项?

时间:2017-07-30 13:03:38

标签: selenium selenium-chromedriver

详细描述

我想将selenium附加到现有的chrome会话中,然后使用我的chrome配置文件调整页面,但是从终端调整页面 我发现这是feasible using debuggerAddress

摘录 -

Launch Chrome from command prompt:
chrome.exe --remote-debugging-port=8181

Sample Code:
        ChromeOptions options = new ChromeOptions();
        options.setExperimentalOption("debuggerAddress", "127.0.0.1:8181");

        WebDriver driver = new ChromeDriver(options);
        driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
        driver.get("http://www.google.com");
        driver.findElement(By.name("q")).sendKeys("test");
        driver.quit();

重现的步骤 -

// close all chrome windows
$ google-chrome-stable --remote-debugging-port=4444
// chrome opened with my profile
$ pry
>  require 'selenium-webdriver'
>  Selenium::WebDriver::Chrome.path = '/usr/bin/google-chrome-stable'
>  Selenium::WebDriver::Chrome.driver_path = '/usr/bin/chromedriver'
>  options = Selenium::WebDriver::Chrome::Options.new
>  # options.add_experimental_option("debuggerAddress", "127.0.0.1:4444") # how????
>  driver = Selenium::WebDriver.for :chrome, options: options

1 个答案:

答案 0 :(得分:0)

ruby​​客户端没有add_experimental_option

改为使用add_option

options = Selenium::WebDriver::Chrome::Options.new
options.add_option("debuggerAddress", "127.0.0.1:4444")