我想将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
答案 0 :(得分:0)
ruby客户端没有add_experimental_option
。
改为使用add_option
:
options = Selenium::WebDriver::Chrome::Options.new
options.add_option("debuggerAddress", "127.0.0.1:4444")