Class: Magnesium::Alert

Inherits:
Object
  • Object
show all
Defined in:
lib/magnesium/elements/alert.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#boxObject

Returns the value of attribute box.



12
13
14
# File 'lib/magnesium/elements/alert.rb', line 12

def box
  @box
end

#browserObject

Returns the value of attribute browser.



13
14
15
# File 'lib/magnesium/elements/alert.rb', line 13

def browser
  @browser
end

Instance Method Details

#element(locate, value) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/magnesium/elements/alert.rb', line 15

def element(locate,value)
  @e = @browser.alert
=begin
begin
  if locate == 'id'
    @e = @browser.button(:id => value.to_s)
  elsif locate == 'name'
    @e = @browser.button(:name => value.to_s)
  elsif locate == 'index'
    @e = @browser.button(:index => value.to_i)
  elsif locate == 'text'
    @e = @browser.button(:text => value.to_s)
  else
    nonfun
    #puts 'M: I need time to grow up.'
  end
rescue
  error
#ensure
end
=end
end

#execute(action, data) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/magnesium/elements/alert.rb', line 38

def execute(action,data)
  begin
    if action == 'text'
      if Config.config["wait"]["isstart"] == "true"
        return @e.when_present(Config.config["wait"]["value"].to_i).text
      elsif Config.config["wait"]["isstart"] == "false"
        return @e.text
      else
 #           error
        puts '...'
      end
    elsif action == 'exists'
      if Config.config["wait"]["isstart"] == "true"
        return @e.when_present(Config.config["wait"]["value"].to_i).exists?
      elsif Config.config["wait"]["isstart"] == "false"
        return @e.exists?
      else
#            error
        puts '...'
      end
    elsif action == 'ok'
      if Config.config["wait"]["isstart"] == "true"
        return @e.when_present(Config.config["wait"]["value"].to_i).ok
      elsif Config.config["wait"]["isstart"] == "false"
        return @e.ok
      else
#            error
        puts '...'
      end
    elsif action == 'close'
      if Config.config["wait"]["isstart"] == "true"
        return @e.when_present(Config.config["wait"]["value"].to_i).close
      elsif Config.config["wait"]["isstart"] == "false"
        return @e.close
      else
#            error
        puts '...'
      end
    elsif action == 'set'
      if Config.config["wait"]["isstart"] == "true"
        return @e.when_present(Config.config["wait"]["value"].to_i).set data.to_s
      elsif Config.config["wait"]["isstart"] == "false"
        return @e.set data.to_s
      else
#            error
        puts '...'
      end
    elsif action == 'wait_until_present'
      return @e.wait_until_present
    elsif action == 'wait_while_present'
      return @e.wait_while_present
    else
#          nonfun
      puts '...'
    end
  #rescue
  #  error
    #ensure
  end
end

#generateObject

def setbox(box)

  @box = box
end

def getbox()
  return @box
end

def setbrowser(browser)
  @browser = browser
end

def getbrowser()
  return @browser
end


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/magnesium/elements/alert.rb', line 115

def generate()
  unless @box.empty?
    @box.collect do |f|
      if f["name"] == 'frame'
        @browser = dealframe(@browser,f["locate"],f["value"])
      elsif f["name"] == 'div'
        @browser = dealdiv(@browser,f["locate"],f["value"])
      elsif f["name"] == 'span'
        @browser = dealspan(@browser,f["locate"],f["value"])
      elsif f["name"] == 'table'
        @browser = dealtable(@browser,f["locate"],f["value"])
      else
   #     nonfun
        puts '...'
      end
    end
  end
end