Ruby: Chrome 浏览器未启动
Ruby: Chrome browser is not launching
最近我安装了 gem 'webdrivers', '~> 4.0'
并尝试启动 chrome 浏览器。但是没用。
代码:
@app = Driver.new(Capybara::Session.new(:selenium_chrome))
Webdrivers::Chromedriver.current_version
错误日志:
An error occurred while loading ./spec/login_spec.rb.
Failure/Error: require_relative '../pages/nav_bar.rb'
SyntaxError:
/Users/madhan_kumaravel/.rvm/gems/ruby-2.2.8/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:83: syntax error, unexpected '.'
....VersionInfo.ProductVersion")&.strip
... ^
/Users/madhan_kumaravel/.rvm/gems/ruby-2.2.8/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:87: syntax error, unexpected '.'
System.call(location, '--product-version')&.strip
^
/Users/madhan_kumaravel/.rvm/gems/ruby-2.2.8/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:91: syntax error, unexpected '.'
System.call(location, '--version')&.strip
As Marek mentioned in the comments, the gem is using the safe navigation operator 仅在 Ruby 2.3 及更高版本中可用。要么升级到 Ruby 2.3,要么将 webdrivers 降级到 3.9.4,例如gem 'webdrivers', '~> 4.0'
。
我浏览了code for 3.9.4,他们似乎没有使用安全导航运算符,所以值得一试。
最近我安装了 gem 'webdrivers', '~> 4.0'
并尝试启动 chrome 浏览器。但是没用。
代码:
@app = Driver.new(Capybara::Session.new(:selenium_chrome))
Webdrivers::Chromedriver.current_version
错误日志:
An error occurred while loading ./spec/login_spec.rb.
Failure/Error: require_relative '../pages/nav_bar.rb'
SyntaxError:
/Users/madhan_kumaravel/.rvm/gems/ruby-2.2.8/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:83: syntax error, unexpected '.'
....VersionInfo.ProductVersion")&.strip
... ^
/Users/madhan_kumaravel/.rvm/gems/ruby-2.2.8/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:87: syntax error, unexpected '.'
System.call(location, '--product-version')&.strip
^
/Users/madhan_kumaravel/.rvm/gems/ruby-2.2.8/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:91: syntax error, unexpected '.'
System.call(location, '--version')&.strip
As Marek mentioned in the comments, the gem is using the safe navigation operator 仅在 Ruby 2.3 及更高版本中可用。要么升级到 Ruby 2.3,要么将 webdrivers 降级到 3.9.4,例如gem 'webdrivers', '~> 4.0'
。
我浏览了code for 3.9.4,他们似乎没有使用安全导航运算符,所以值得一试。