Selenium WebDriver功能调试

时间:2019-07-16 05:26:52

标签: ruby selenium google-chrome

由Capybara启动chrome后,我需要获取chromeOptions进行检查。因为代理和用户代理不起作用

Capybara.register_driver :selenium do |app|
      caps = Selenium::WebDriver::Remote::Capabilities.chrome(
        "chromeOptions" => {
          "args" => [
            "--headless",
            "--remote-debugging-port=9222",
            "--proxy-server=http://127.0.0.1:#{proxy_server.port}",
            "--disable-dev-shm-usage",
            # '--blink-settings=imagesEnabled=false',
            "window-size=1440,900",
            "--no-sandbox",
            "--user-agent='#{account[:user_agent]}'"
          ]
        }
      )
      Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: caps)
    end

    Capybara.javascript_driver = :chrome
    Capybara.configure do |config|
      config.default_max_wait_time = 20 # seconds
      config.default_driver = :selenium
    end
    session = Capybara::Session.new(:selenium)


    session.visit("https://www.google.com/")

0 个答案:

没有答案