Capybara open an html file in my computer

你说的曾经没有我的故事 提交于 2021-02-07 04:26:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!