提问人:Kevin W. 提问时间:10/6/2023 最后编辑:Kevin W. 更新时间:10/7/2023 访问量:102
在 Heroku slug 上对 Rails 7 应用程序运行无头自动化系统测试时,Selenium-Webdriver 中出现错误
Error in Selenium-Webdriver when running headless automated system tests against Rails 7 app on Heroku slug
问:
我的系统测试在本地运行良好,也可以作为 GitHub Action 运行,但当我尝试在使用 Heroku 部署的测试服务器上运行时失败。它失败,并出现以下错误:
-----> Running test command `bin/rails test:system`...
Chrome Shim ENV variable:
/app/.apt/usr/bin/google-chrome-stable
Run options: --seed 1107
# Running:
loading test data
E
Error:
UserStory6Test#test_modify_an_existing_comment_to_an_empty_string:
Selenium::WebDriver::Error::SessionNotCreatedError: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from chrome location /app/.cache/selenium/chrome/linux64/117.0.5938.149/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
我遵循了我能找到的可用的 heroku 文档,将以下内容添加到我的 test_helper.rb 中:
#This code to provide correct path to the chrome library on heroku test environment
chrome_bin = ENV.fetch('GOOGLE_CHROME_SHIM', nil)
chrome_opts = chrome_bin ? { "chromeOptions" => { "binary" => chrome_bin } } : {}
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(chrome_opts)
)
end
Capybara.javascript_driver = :chrome
和这个app.json文件:
{
"buildpacks": [
{ "url": "heroku/ruby" },
{ "url": "heroku/chromedriver" },
{ "url": "heroku/google-chrome" }
],
"environments": {
"test": {
"addons": ["heroku-postgresql:in-dyno"],
"scripts": {
"test": "bin/rails test:system"
}
}
}
}
以下是 Heroku 测试设置日志中的一些相关信息:
-----> Fetching heroku/chromedriver buildpack...
buildpack downloaded
-----> Fetching heroku/google-chrome buildpack...
buildpack downloaded
...
Using selenium-webdriver 4.11.0
...
-----> chromedriver app detected
-----> Looking up latest chromedriver version...
-----> Downloading chromedriver v117.0.5938.149...
Archive: /tmp/chromedriver.zip
inflating: /app/.chromedriver/bin/LICENSE.chromedriver
inflating: /app/.chromedriver/bin/chromedriver
-----> Creating chromedriver export scripts...
-----> Google Chrome app detected
-----> Installing Google Chrome from the stable channel.
...
-----> Creating google-chrome shims
以下是 Heroku 测试运行日志中的一些相关信息:
-----> Running test command `bin/rails test:system`...
Chrome Shim ENV variable:
/app/.apt/usr/bin/google-chrome-stable
Run options: --seed 1107
# Running:
loading test data
E
Error:
UserStory6Test#test_modify_an_existing_comment_to_an_empty_string:
Selenium::WebDriver::Error::SessionNotCreatedError: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from chrome location /app/.cache/selenium/chrome/linux64/117.0.5938.149/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
test/system/user_story_6_test.rb:53:in `block in <class:UserStory6Test>'
Error:
UserStory6Test#test_modify_an_existing_comment_to_an_empty_string:
Selenium::WebDriver::Error::SessionNotCreatedError: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from chrome location /app/.cache/selenium/chrome/linux64/117.0.5938.149/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
#0 0x5653a7a39933 <unknown>
#1 0x5653a77136f7 <unknown>
#2 0x5653a7746a55 <unknown>
#3 0x5653a7742bbc <unknown>
#4 0x5653a778577a <unknown>
#5 0x5653a777c3d3 <unknown>
#6 0x5653a774ee64 <unknown>
#7 0x5653a774fc4e <unknown>
#8 0x5653a79ff558 <unknown>
#9 0x5653a7a034a0 <unknown>
#10 0x5653a7a0d97c <unknown>
#11 0x5653a7a040b8 <unknown>
#12 0x5653a79cfcdf <unknown>
#13 0x5653a7a28048 <unknown>
#14 0x5653a7a28219 <unknown>
#15 0x5653a7a38ac3 <unknown>
#16 0x7fed2cefeb43 <unknown>
/app/vendor/bundle/ruby/3.1.0/gems/selenium-webdriver-4.11.0/lib/selenium/webdriver/remote/response.rb:55:in `assert_ok'
答: 暂无答案
评论