首页 > 解决方案 > Chromedriver 不允许在 Windows 上使用 jruby 的无头模式 - Childprocess 错误

问题描述

这是代码

puts 'requiring selenium...'
require "selenium-webdriver"

# configure the driver to run in headless mode
puts 'initializing options...'
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')

puts 'initiating driver..'
driver = Selenium::WebDriver.for :chrome, options: options

puts 'navigating to google.com...'
driver.navigate.to "https://google.com/"

puts 'adjusting window size'
driver.manage.window.resize_to(800, 800)

puts 'capturing screenshot...'
driver.save_screenshot "google.png"

启动驱动程序时出现以下错误

ChildProcess::Error: Unknown error (Windows says "The operation completed successfully.", but it did not.)

环境
jruby 1.7 (ruby 2.0)
selenium-webdriver 3.12.0 (latest)
chromedriver 2.38 (latest)
windows 7

标签: rubywindowsselenium-chromedriverjrubybrowser-automation

解决方案


推荐阅读