【问题标题】:goog:chromeOptions being ignored completely using RSpec, Capybara, and Selenium使用 RSpec、Capybara 和 Selenium 完全忽略 goog:chromeOptions
【发布时间】:2019-02-20 17:00:01
【问题描述】:

还有其他人有这个问题吗?似乎某处 goog:chromeOptions 没有正确传递给 chromedriver - 这导致 Chrome 仅以默认选项打开。

我正在使用以下 Capybara/Selenium 配置:

Capybara.register_driver :chrome do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    'goog:chromeOptions': {
      args: %w[ start-maximized ]
    }
  )

  Capybara::Selenium::Driver.new(
    app,
    browser: :chrome,
    desired_capabilities: capabilities,
    driver_opts: {
      log_path: "./tmp/chrome#{Time.now.to_i}.log",
      verbose: true
    }
  )
end

Capybara.javascript_driver = :chrome

但是,当我打开 Capybara 会话日志时,goog:chromeOptions 根本没有设置。这就是我的 Chrome 窗口没有最大化的原因吗?

会话日志:

[1550680994.143][INFO]: COMMAND InitSession {
   "capabilities": {
      "firstMatch": [ {
         "browserName": "chrome",
         "goog:chromeOptions": {
           //nothing is here???  should have args!
         }
      } ]
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "cssSelectorsEnabled": true,
      "goog:chromeOptions": {
        //nothing is here???  should have args!
      },
      "javascriptEnabled": true,
      "nativeEvents": false,
      "platform": "ANY",
      "rotatable": false,
      "takesScreenshot": false,
      "version": ""
   }
}

操作系统:

Ubuntu 18.04

我的环境:

ruby 2.6.1
capybara (2.18.0)
selenium-webdriver (3.13.0)
ChromeDriver 2.37.544315

每次我运行 Selenium 测试时,窗口都不会最大化。但这不是另一个“屏幕未最大化”的帖子(已经有很多帖子了)。这似乎是我的选项没有被正确解析的问题?我不明白怎么了。我正在尽我所能遵循所有自述文件和指南。它只是不工作:(

【问题讨论】:

    标签: selenium rspec capybara


    【解决方案1】:

    通过升级 Capybara 和 Selenium Webdriver 来修复它!

    capybara (3.13.2)
    selenium-webdriver (3.141.0)
    

    现在调试日志有我期望看到的内容:

    [1550686685.534][INFO]: COMMAND InitSession {
       "capabilities": {
          "firstMatch": [ {
             "browserName": "chrome",
             "goog:chromeOptions": {
                "args": [ "start-maximized" ]
             }
          } ]
       },
       "desiredCapabilities": {
          "browserName": "chrome",
          "cssSelectorsEnabled": true,
          "goog:chromeOptions": {
             "args": [ "start-maximized" ]
          },
          "javascriptEnabled": true,
          "nativeEvents": false,
          "platform": "ANY",
          "rotatable": false,
          "takesScreenshot": false,
          "version": ""
       }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-28
      • 1970-01-01
      • 2015-09-16
      • 1970-01-01
      • 2012-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多