В настоящее время я пишу тесты с использованием Rails5, Rspec, Selenium и webdrivers gems.
Однако я получаю сообщение об ошибке Webdrivers :: BrowserNotFound и не могу его запустить.
Я думаю, что это связано сСелену не удалось найти ChromeDriver.
Тем не менее, эта проблема должна была быть решена с помощью гема webdrivers, но, похоже, он не работает должным образом.
Подробности будут написаны ниже.
1.1) Failure/Error: visit hoges_index_path
Webdrivers::BrowserNotFound:
Failed to find Chrome binary.
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:21:in `location'
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/chrome_finder.rb:10:in `version'
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/chromedriver.rb:46:in `browser_version'
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/chromedriver.rb:106:in `release_version'
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/chromedriver.rb:32:in `latest_version'
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/common.rb:136:in `correct_binary?'
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/common.rb:92:in `update'
# /usr/local/bundle/gems/webdrivers-4.1.2/lib/webdrivers/chromedriver.rb:119:in `block in <top (required)>'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/service.rb:133:in `binary_path'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/service.rb:94:in `initialize'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/service.rb:41:in `new'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/service.rb:41:in `chrome'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/driver.rb:299:in `service_url'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/chrome/driver.rb:40:in `initialize'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/driver.rb:46:in `new'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/driver.rb:46:in `for'
# /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver.rb:88:in `for'
# /usr/local/bundle/gems/capybara-3.28.0/lib/capybara/selenium/driver.rb:49:in `browser'
# /usr/local/bundle/gems/capybara-3.28.0/lib/capybara/selenium/driver.rb:68:in `visit'
# /usr/local/bundle/gems/capybara-3.28.0/lib/capybara/session.rb:276:in `visit'
# /usr/local/bundle/gems/capybara-3.28.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
# ./spec/views/hoge/index_spec.rb:28:in `block (2 levels) in <top (required)>'
RSpec.feature 'HogeIndex', type: :system do
before(:each) do
visit hoges_index_path
end
scenario 'hoge' do
expect(all('.hoge').count).to eq 1
end
end
RSpec.configure do |config|
~~~
Capybara.register_driver :selenium_chrome_headless do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--no-sandbox'
browser_options.args << '--disable-gpu'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end
config.before(:each) do |example|
if example.metadata[:type] == :system
driven_by :selenium_chrome_headless, screen_size: [700, 700]
end
end
~~~~
end
Я также включил ведение журнала отладки Webdrivers. Вот журнал в то время.
2019-10-19 02:12:03 DEBUG Webdrivers Checking current version
2019-10-19 02:12:03 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
2019-10-19 02:12:04 DEBUG Webdrivers Checking current version
2019-10-19 02:12:04 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
F2019-10-19 02:12:10 DEBUG Webdrivers Checking current version
2019-10-19 02:12:10 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
2019-10-19 02:12:11 DEBUG Webdrivers Checking current version
2019-10-19 02:12:11 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
F2019-10-19 02:12:17 DEBUG Webdrivers Checking current version
2019-10-19 02:12:17 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
2019-10-19 02:12:18 DEBUG Webdrivers Checking current version
2019-10-19 02:12:18 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
F2019-10-19 02:12:25 DEBUG Webdrivers Checking current version
2019-10-19 02:12:25 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
2019-10-19 02:12:26 DEBUG Webdrivers Checking current version
2019-10-19 02:12:26 DEBUG Webdrivers /root/.webdrivers/chromedriver is not already downloaded
F
Я буду ждать вашего ответа.