问题
I have an html file in my computer and I want to open that file using Capybara to test it. Could you help me to solve this problem?
P/S: That html file is created automatically in my app. I do appreciate any idea helping me to solve this problem. Thanks :)
UPDATE: Based on the capybara source code here, I found that I should use Capybara.current_session.driver.visit instead of page.visit. The problem is solved
回答1:
I can confirm that the update to the question works (assuming the file is in the current directory):
filename = 'foo.html'
Capybara.current_session.driver.visit filename
回答2:
If your file is located at /path/to/folder/file.html
Set Capybara.app
to a folder containing this file:
Capybara.app = Rack::File.new('/path/to/folder')
and then
visit 'file.html'
should work for you
See also this gist for example
来源:https://stackoverflow.com/questions/19674013/capybara-open-an-html-file-in-my-computer