Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# Add caption feild element in the page object
# acceptance/pages/content_items_edit_page.rb
element :photohud_caption_tinymce, :xpath, "//div[contains(@class, 'photo-mode-container')]//textarea[contains(@name, 'caption')]"
# acceptance/content_item/story_content_item_spec.rb
scenario "use related item photo hud to edit caption field" do
# Can set an expectation on an element to be visible with have_x
# In this case its checking that the edit_page has the photo hud element
expect(edit_page).to have_photo_hud
# Using .wait_for_x is a good way to wait on an ajax request to complete
# In this case its waiting for the photo hud button to appear for the given # of seconds (5)
edit_page.execute_script(%Q(tinyMCE.get("#{edit_page.photohud_caption_tinymce(visible: false)[:id]}").setContent("Test")))
# This is a tinymce thing to ensure that it writes to the textarea field for when the form submits
# Make sure the hud has been remove from the page
expect(edit_page).to have_no_css('.hud_container')
expect(@story1.related_content_items.first.caption).to eql("<p>Test</p>\r\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment