티스토리 뷰
capybara-screenshot README- https: //github.com/mattheworiordan/capybara-screenshot#custom-screenshot-directory 및 https://github.com/mattheworiordan/capybara-screenshot#custom-screenshot-filename 에 설명 된대로 디렉토리에 대해 Capybara.save_path를 설정하고 (후 블록이 아닌 한 번만 지정) Capybara :: Screenshot.register_filename_prefix_formatter를 사용하여 사용 된 파일 이름을 재정의해야합니다.
-------------------나는 다음과 같이했다 (@Tom Walpole에게 감사드립니다).
RSpec.configure do |config|
config.include LoginHelper
config.include RSpec::Matchers
config.include Capybara::DSL
Selenium::WebDriver::Chrome.driver_path = '../Resources/chromedriver.exe'
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.save_path = "../Reports"
config.after { |example_group| CapybaraScreenshot.save_and_open_page_path if example_group.exception }
Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
"screenshot_#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//,'')}"
end
end
출처
https://stackoverflow.com/questions/39920130
댓글