Module: Webdrone

Defined in:
lib/webdrone.rb,
lib/webdrone/clic.rb,
lib/webdrone/conf.rb,
lib/webdrone/ctxt.rb,
lib/webdrone/exec.rb,
lib/webdrone/find.rb,
lib/webdrone/form.rb,
lib/webdrone/html.rb,
lib/webdrone/logg.rb,
lib/webdrone/mark.rb,
lib/webdrone/open.rb,
lib/webdrone/shot.rb,
lib/webdrone/text.rb,
lib/webdrone/vrfy.rb,
lib/webdrone/wait.rb,
lib/webdrone/xlsx.rb,
lib/webdrone/error.rb,
lib/webdrone/xpath.rb,
lib/webdrone/browser.rb,
lib/webdrone/version.rb

Defined Under Namespace

Modules: XPath Classes: Browser, Clic, Conf, Ctxt, Exec, Find, Form, Html, Logs, Mark, MethodLogger, Open, Shot, Text, Vrfy, Wait, WebdroneError, Xlsx

Constant Summary collapse

VERSION =
'1.18.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.irb_setup_doneObject

Returns the value of attribute irb_setup_done.



37
38
39
# File 'lib/webdrone.rb', line 37

def irb_setup_done
  @irb_setup_done
end

.running_pryObject

Returns the value of attribute running_pry.



37
38
39
# File 'lib/webdrone.rb', line 37

def running_pry
  @running_pry
end

Class Method Details

.create(*args, **kwargs) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/webdrone.rb', line 39

def create(*args, **kwargs)
  a0 = Webdrone::Browser.new(*args, **kwargs)
  if block_given?
    begin
      yield a0
    rescue StandardError => error
      Webdrone.report_error(a0, error)
    ensure
      a0.quit
    end
  else
    a0
  end
end

.irb_console(binding = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/webdrone.rb', line 55

def self.irb_console(binding = nil)
  puts 'Webdrone: Webdrone.irb_console IS DEPRECATED, please use a0.console instead.'
  return if IRB.CurrentContext && !binding

  binding ||= Kernel.binding.of_caller(1)
  IRB.start_session(binding)
end

.pry_console(binding = nil) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/webdrone.rb', line 64

def self.pry_console(binding = nil)
  if Webdrone.running_pry
    puts 'Webdrone: pry console already running.'
  else
    Webdrone.running_pry = true
    binding ||= Kernel.binding.of_caller(1)
    binding.pry
    Webdrone.running_pry = false
  end
end

.report_error(a0, exception) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/webdrone/error.rb', line 134

def self.report_error(a0, exception)
  return if a0.conf.error == :ignore

  if exception.class != WebdroneError
    exception = WebdroneError.new(exception.message, exception, a0, Kernel.binding.callers)
    if a0.conf.developer && exception.binding && %i[raise_report].include?(a0.conf.error)
      exception.write_title "STARTING DEVELOPER CONSOLE ON ERROR"
      exception.dump_error_report
      a0.console exception.binding
    end
  end

  raise exception if %i[raise raise_report].include? a0.conf.error
end