Module: Calabash::Cucumber::ConsoleHelpers
- Defined in:
- lib/calabash-cucumber/console_helpers.rb
Overview
A collection of methods that help you use console.
Instance Method Summary collapse
-
#clear ⇒ Object
Clear the console history.
-
#clear_clipboard ⇒ Object
Clear the clipboard.
-
#copy ⇒ Object
Copy all the commands entered in the current console session into the OS Clipboard.
-
#ids ⇒ Object
Print the visible element ids.
-
#labels ⇒ Object
Print the visible element labels.
-
#marks ⇒ Object
List the visible element with all marks.
-
#puts_message_of_the_day ⇒ Object
Print a message to the console.
-
#quiet ⇒ Object
Turn off debug logging.
-
#text ⇒ Object
Print the visible element texts.
-
#tree ⇒ Object
Print a representation of the current view hierarchy.
-
#verbose ⇒ Object
Turn on debug logging.
Instance Method Details
#clear ⇒ Object
Clear the console history.
79 80 81 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 79 def clear ConsoleHelpers.clear end |
#clear_clipboard ⇒ Object
Clear the clipboard
74 75 76 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 74 def clear_clipboard ConsoleHelpers.clear_clipboard! end |
#copy ⇒ Object
Copy all the commands entered in the current console session into the OS Clipboard.
69 70 71 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 69 def copy ConsoleHelpers.copy end |
#ids ⇒ Object
Print the visible element ids.
14 15 16 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 14 def ids accessibility_marks(:id) end |
#labels ⇒ Object
Print the visible element labels.
19 20 21 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 19 def labels accessibility_marks(:label) end |
#marks ⇒ Object
List the visible element with all marks.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 29 def marks opts = {:print => false, :return => true } res = accessibility_marks(:id, opts).each { |elm|elm << :id } res.concat(accessibility_marks(:label, opts).each { |elm| elm << :label }) res.concat(text_marks(opts).each { |elm| elm << :text }) max_width = 0 res.each { |elm| len = elm[0].length max_width = len if len > max_width } counter = -1 res.sort.each { |elm| printf("%4s %-6s => %#{max_width}s => %s\n", "[#{counter = counter + 1}]", elm[2], elm[0], elm[1]) } true end |
#puts_message_of_the_day ⇒ Object
Print a message to the console.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 84 def = [ "Let's get this done!", "Ready to rumble.", "Enjoy.", "Remember to breathe.", "Take a deep breath.", "Isn't it time for a break?", "Can I get you a coffee?", "What is a calabash anyway?", "Smile! You are on camera!", "Let op! Wild Rooster!", "Don't touch that button!", "I'm gonna take this to 11.", "Console. Engaged.", "Your wish is my command.", "This console session was created just for you.", "Den som jager to harer, får ingen.", "Uti, non abuti.", "Non Satis Scire", "Nullius in verba", "Det ka æn jå væer ei jált", "Dzień dobry", "Jestem tu by ocalić świat" ] puts RunLoop::Color.green("Calabash says, \"#{.shuffle.first}\"") end |
#quiet ⇒ Object
Turn off debug logging.
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 125 def quiet if RunLoop::Environment.debug? ENV["DEBUG"] = "0" puts RunLoop::Color.cyan("Turned off debug logging.") else puts RunLoop::Color.cyan("Debug logging is already turned off.") end true end |
#text ⇒ Object
Print the visible element texts.
24 25 26 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 24 def text text_marks end |
#tree ⇒ Object
Print a representation of the current view hierarchy.
7 8 9 10 11 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 7 def tree hash = http_fetch_view_hierarchy dump_json_data(hash) true end |
#verbose ⇒ Object
Turn on debug logging.
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/calabash-cucumber/console_helpers.rb', line 113 def verbose if RunLoop::Environment.debug? puts RunLoop::Color.cyan("Debug logging is already turned on.") else ENV["DEBUG"] = "1" puts RunLoop::Color.cyan("Turned on debug logging.") end true end |