fill_in_epic_editor with Capybara + Selenium
eliotsykes opened this issue · 1 comments
eliotsykes commented
# File: spec/support/epic_editor_helper.rb
module EpicEditorHelper
def fill_in_epic_editor(text)
# Epic Editor consists of:
# - a parent iframe with id 'epiceditor-1234' where 1234 is random.
# - a child iframe (within the parent iframe) with id 'epiceditor-editor-frame'.
# - a contenteditable body (within the child iframe).
# Use CSS attribute prefix selector (^=) to find iframe with id
# beginning with 'epiceditor-' to match first parent iframe in page
parent_iframe_node = find('iframe[id^=epiceditor-]')
within_frame(parent_iframe_node) do
child_iframe_id = 'epiceditor-editor-frame'
within_frame(child_iframe_id) do
find('body[contenteditable]').set(text)
end
end
end
end
RSpec.configure do |config|
config.include EpicEditorHelper, type: :feature
end
Usage in feature specs (must be js: true
feature specs):
scenario "..." do
fill_in_epic_editor "text goes here"
end
eliotsykes commented
See related notes from article: https://eliotsykes.com/testing-epic-editor