Class: UtilityCommands

Inherits:
Thor
  • Object
show all
Defined in:
lib/commands/utility_commands.rb

Instance Method Summary collapse

Instance Method Details

#browser(default_browser = nil) ⇒ Object



32
33
34
35
36
# File 'lib/commands/utility_commands.rb', line 32

def browser(default_browser = nil)
  Utilities.browser = default_browser if default_browser
  selected_options = options[:opts]
  browser_options(selected_options) if selected_options || options[:delete]
end

#browser_options(*opts) ⇒ Object



42
43
44
45
# File 'lib/commands/utility_commands.rb', line 42

def browser_options(*opts)
  Utilities.browser_options = opts unless opts.empty?
  Utilities.delete_browser_options if options[:delete]
end

#desktopObject



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/commands/utility_commands.rb', line 104

def desktop
  require_relative '../utilities/desktop_downloader'
  version = DesktopDownloader.latest_version
  unless version
    say 'Could not reach GitHub releases. Check your internet connection.', :red
    return
  end

  say "Raider Desktop v#{version} available for #{DesktopDownloader.platform_display_name}"
  DesktopDownloader.download(options[:path])
  say 'Raider Desktop downloaded successfully!', :green
end

#headless(toggle) ⇒ Object



49
50
51
52
53
54
# File 'lib/commands/utility_commands.rb', line 49

def headless(toggle)
  enabled = %w[on true 1 yes].include?(toggle.downcase)
  Utilities.headless = enabled
  state = enabled ? 'enabled' : 'disabled'
  say "Headless mode #{state}", :green
end

#path(default_path) ⇒ Object



15
16
17
18
# File 'lib/commands/utility_commands.rb', line 15

def path(default_path)
  type = options.empty? ? 'page' : options.keys.first
  Utilities.send("#{type}_path=", default_path)
end

#platform(platform) ⇒ Object



91
92
93
# File 'lib/commands/utility_commands.rb', line 91

def platform(platform)
  Utilities.platform = platform
end

#raidObject



62
63
64
65
66
67
68
69
# File 'lib/commands/utility_commands.rb', line 62

def raid
  selected_options = options[:opts]
  if options[:parallel]
    Utilities.parallel_run(selected_options)
  else
    Utilities.run(selected_options)
  end
end

#start_appiumObject



96
97
98
# File 'lib/commands/utility_commands.rb', line 96

def start_appium
  system 'appium  --base-path /wd/hub'
end

#timeout(seconds) ⇒ Object



79
80
81
# File 'lib/commands/utility_commands.rb', line 79

def timeout(seconds)
  Utilities.timeout = seconds
end

#url(default_url) ⇒ Object



22
23
24
# File 'lib/commands/utility_commands.rb', line 22

def url(default_url)
  Utilities.url = default_url
end

#viewport(dimensions) ⇒ Object



85
86
87
# File 'lib/commands/utility_commands.rb', line 85

def viewport(dimensions)
  Utilities.viewport = dimensions
end