(Selenium ruby) How to add debuggerAddress experimental option?

感情迁移 提交于 2019-12-13 07:31:27

问题


Discription

I want to attach selenium to existing session of chrome, and then tweak pages using my chrome profile, but from terminal I have found that this is feasible using debuggerAddress

Excerpt -

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();

Steps to reproduce -

// 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:


The ruby client doesn't have add_experimental_option.

Use add_option instead:

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


来源:https://stackoverflow.com/questions/45400113/selenium-ruby-how-to-add-debuggeraddress-experimental-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!