Context:我使用Rails-New设置了一个新系统,将其设置为DevContainer。因此,开发环境在Docker内部运行。我正在使用停靠的硒铬来进行测试。我正在使用设计

问题描述 投票:0回答:0
HERHE的功能/支持/config.rb

require "capybara/cucumber" require "selenium-webdriver" Capybara.register_driver :selenium_remote_chrome do |app| options = Selenium::WebDriver::Chrome::Options.new options.add_argument("--window-size=1400,1400") options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") Capybara::Selenium::Driver.new( app, browser: :remote, url: "http://#{ENV.fetch("SELENIUM_HOST")}:4444/wd/hub", options: options ) end Capybara.configure do |config| config.run_server = true config.server_port = ENV.fetch("CAPYBARA_SERVER_PORT", 3015).to_i config.server_host = "0.0.0.0" config.default_driver = :selenium_remote_chrome config.app_host = "http://rails-app:#{config.server_port}" end

功能文件;-

Background: Given a user exists with email "[email protected]" and password "password123" Rule: A user can login with the correct email and password Scenario: User logs in successfully When I go to the login page And I fill in "Email" with "[email protected]" And I fill in "Password" with "password123" And I press "Log in" And I wait for the page to load Then I should see "Dashboard" And I should see "Log out"

步骤; -

Given("a user exists with email {string} and password {string}") do |email, password| User.create!(email: email, password: password, password_confirmation: password) expect(User.count).to eq(1) # Ensure that the user was created u = User.first expect(u.valid_password?(password)).to be true # Ensure that the password is correct end When("I go to the login page") do visit new_user_session_path end When("I fill in {string} with {string}") do |field, value| fill_in field, with: value end When("I press {string}") do |button| click_button button end Then("I should see {string}") do |text| expect(page).to have_content(text) end And("I wait for the page to load") do sleep 1 end And("I wait for {int} seconds") do |seconds| sleep seconds end
和log/test.log;  - 

Completed 401 Unauthorized in 2ms (ActiveRecord: 0.2ms (1 query, 0 cached) | GC: 0.0ms) Processing by Devise::SessionsController#new as TURBO_STREAM Parameters: {"user"=>{"email"=>"[email protected]", "password"=>"password123"}, "commit"=>"Log in"} Rendering layout layouts/application.html.haml Rendering devise/sessions/new.html.haml within layouts/application Rendered devise/shared/_links.html.haml (Duration: 0.3ms | GC: 0.0ms) Rendered devise/sessions/new.html.haml within layouts/application (Duration: 2.5ms | GC: 0.0ms) Rendered layout layouts/application.html.haml (Duration: 3.3ms | GC: 0.0ms)
注意我从日志过滤中删除了电子邮件和密码,以便我可以看到传递的值。
login在手动运行时起作用

任何想法会导致这个问题?
    

溶解了它。我需要使用``databasecleaner.strategy =:truncation``而不是:trassaction
过去,我一直在机架内运行黄瓜测试,浏览器在本地受到控制,以便浏览器可见创建的记录。

但是在码头容器内运行时,我不能这样做。因此,我必须使用远程运行的停靠硒。因此,默认数据库清洁程序策略:事务无法正常工作,因为在交易中会创建记录,因此对于远程硒是看不见的。 我切换到:截断一切都起作用。

docker selenium-webdriver devise cucumber
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.