Module: Helper
- Includes:
- Capybara::DSL
- Defined in:
- lib/SkeletonApi/features/support/helper.rb,
lib/SkeletonWeb/features/support/helper.rb
Instance Method Summary collapse
- #create_message_pubsub(topic, body) ⇒ Object
- #element_wait(time) ⇒ Object
- #take_screenshot(scenario) ⇒ Object
- #wait_until_element_exist(element) ⇒ Object
- #wait_until_text_exist(element, text) ⇒ Object
Instance Method Details
#create_message_pubsub(topic, body) ⇒ Object
2 3 4 5 |
# File 'lib/SkeletonApi/features/support/helper.rb', line 2 def (topic, body) topic = @pubsub.topic topic topic.publish body.to_json end |
#element_wait(time) ⇒ Object
34 35 36 |
# File 'lib/SkeletonWeb/features/support/helper.rb', line 34 def element_wait(time) sleep(time) end |
#take_screenshot(scenario) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/SkeletonWeb/features/support/helper.rb', line 8 def take_screenshot(scenario) scn_name = scenario.name.gsub(%r{([_@#!%()\-=;><,{}\~\[\]\.\/\?\"\*\^\$\+\-]+)}, '_') screenshot = scenario.failed? ? "#{Dir.pwd}/report/screenshots/test_failed/#{scn_name}.png" : "#{Dir.pwd}/report/screenshots/test_passed/#{scn_name}.png" screenshot = screenshot.tr!(' ', '_') if screenshot.include?(' ') page.save_screenshot(screenshot) attach(screenshot, 'image/png') end |
#wait_until_element_exist(element) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/SkeletonWeb/features/support/helper.rb', line 25 def wait_until_element_exist(element) 300.times do find(element, wait: 0.5) break rescue StandardError sleep 0.1 end end |
#wait_until_text_exist(element, text) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/SkeletonWeb/features/support/helper.rb', line 16 def wait_until_text_exist(element, text) 300.times do find(element).assert_text(text) == true break rescue StandardError sleep 0.1 end end |