Class: Webdrone::Vrfy

Inherits:
Object
  • Object
show all
Defined in:
lib/webdrone/vrfy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a0) ⇒ Vrfy

Returns a new instance of Vrfy.



11
12
13
# File 'lib/webdrone/vrfy.rb', line 11

def initialize(a0)
  @a0 = a0
end

Instance Attribute Details

#a0Object

Returns the value of attribute a0.



9
10
11
# File 'lib/webdrone/vrfy.rb', line 9

def a0
  @a0
end

Instance Method Details

#button(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil) ⇒ Object



33
34
35
36
37
# File 'lib/webdrone/vrfy.rb', line 33

def button(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
  vrfy @a0.find.button(text, n: n, visible: visible), attr: attr, eq: eq, contains: contains
rescue => exception
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
end

#css(text, attr: nil, eq: nil, contains: nil) ⇒ Object



21
22
23
24
25
# File 'lib/webdrone/vrfy.rb', line 21

def css(text, attr: nil, eq: nil, contains: nil)
  vrfy @a0.find.css(text), attr: attr, eq: eq, contains: contains
rescue => exception
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
end

#id(text, attr: nil, eq: nil, contains: nil) ⇒ Object



15
16
17
18
19
# File 'lib/webdrone/vrfy.rb', line 15

def id(text, attr: nil, eq: nil, contains: nil)
  vrfy @a0.find.id(text), attr: attr, eq: eq, contains: contains
rescue => exception
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
end


27
28
29
30
31
# File 'lib/webdrone/vrfy.rb', line 27

def link(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
  vrfy @a0.find.link(text, n: n, visible: visible), attr: attr, eq: eq, contains: contains
rescue => exception
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
end

#on(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil) ⇒ Object



39
40
41
42
43
# File 'lib/webdrone/vrfy.rb', line 39

def on(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
  vrfy @a0.find.on(text, n: n, visible: visible), attr: attr, eq: eq, contains: contains
rescue => exception
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
end

#option(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil) ⇒ Object



45
46
47
48
49
# File 'lib/webdrone/vrfy.rb', line 45

def option(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
  vrfy @a0.find.option(text, n: n, visible: visible), attr: attr, eq: eq, contains: contains
rescue => exception
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
end

#vrfy(item, attr: nil, eq: nil, contains: nil) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/webdrone/vrfy.rb', line 57

def vrfy(item, attr: nil, eq: nil, contains: nil)
  if attr != nil
    r = item.attribute(attr) == eq if eq != nil
    r = item.attribute(attr).include? contains if contains != nil
  elsif eq != nil
    r = item.text == eq
  elsif contains != nil
    r = item.text.include? contains
  end
  if r == false
    targ = "eq: [#{eq}]" if eq
    targ = "contains: [#{contains}]" if contains
    if attr != nil
      raise Exception.new "ERROR: Attribute [#{attr}] value [#{item.attribute(attr)}] does not comply #{targ}"
    else
      raise Exception.new "ERROR: Value [#{item.text}] does not comply #{targ}"
    end
  end
end

#xpath(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil) ⇒ Object



51
52
53
54
55
# File 'lib/webdrone/vrfy.rb', line 51

def xpath(text, n: 1, visible: true, attr: nil, eq: nil, contains: nil)
  vrfy @a0.find.xpath(text, n: n, visible: visible), attr: attr, eq: eq, contains: contains
rescue => exception
  Webdrone.report_error(@a0, exception, Kernel.caller_locations)
end