Class: LdsCheckbox

Inherits:
Object
  • Object
show all
Defined in:
lib/TNR360/components/lds_checkbox.rb

Instance Method Summary collapse

Constructor Details

#initialize(browser, idField, idBlock = nil, idScreen = nil) ⇒ LdsCheckbox

constructor



18
19
20
21
22
23
24
25
# File 'lib/TNR360/components/lds_checkbox.rb', line 18

def initialize(browser,idField,idBlock=nil,idScreen=nil)
  @browser =browser
  @idField= idField
  @idBlock=idBlock
  @idScreen=idScreen
  update
  @exists
end

Instance Method Details

#checkObject

LdsScreen Actions



141
142
143
144
145
146
# File 'lib/TNR360/components/lds_checkbox.rb', line 141

def check
  @browser.div(:id => @idField).checkbox(:index => 0).when_present.set
  @checked=true
  @exists=true
  update
end

#elementExists?(idElement) ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/TNR360/components/lds_checkbox.rb', line 92

def elementExists?(idElement)
  #this method assumes the screen/tab is already loaded
  oneIsVisible=false
  #if element not yet available in screen, wait for some time
  if (!@browser.div(:id => idElement).checkbox(:index => 0).exists?)
    @browser.div(:id => idElement).checkbox(:index => 0).when_present(10)
    oneIsVisible=true
  else
    if (!@browser.divs(:id => idElement).visible?)
      @browser.div(:id => idElement).each do |field|
        if field.visible?
          oneIsVisible=true
          break
        end
      end
      if !oneIsVisible
        @browser.div(:id => idElement).checkbox(:index => 0).when_present(10)
        oneIsVisible=true
      end
    end
  end
  oneIsVisible
end

#findElement(idElement) ⇒ Object

method locate current element



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
# File 'lib/TNR360/components/lds_checkbox.rb', line 54

def findElement idElement

  # @browser.div(:id => idElement).radio(:index => 0)
  @current_element=nil

  #wait for screen to become visible (find screen forcefully)
  proc=Proc.new {isScreenDisplayed }
  puts 'Screen found = '+ force_find_element(proc).to_s

  #wait for screen to become visible (find screen forcefully)
  proc=Proc.new {elementExists?(idElement) }
  @exists=force_find_element(proc)
  puts 'CheckBox found = '+@exists.to_s

  if (@browser.divs(:id => idElement).length>1 && @idBlock!=nil)
    #utiliser le id bloc
    @bloc=LdsBlock.new(@browser, @idBlock)
    @current_element=@bloc.getElement.div(:id => idElement).checkbox(:index => 0).when_present
  else
    if (@browser.divs(:id => idElement).length>1)
      @browser.divs(:id => idElement).each do |field|
        if field.visible?
          @current_element=field.checkbox(:index => 0)
          break
        end
      end
    else
      @current_element=@browser.div(:id => idElement).checkbox(:index => 0).when_present
    end
  end
  if @current_element.visible?
    puts 'element is visible'
  else
    puts 'element is NOT visible'
  end
  @current_element
end

#getElementObject

Getters



158
159
160
# File 'lib/TNR360/components/lds_checkbox.rb', line 158

def getElement
  @current_element
end

#getIdBlockObject



165
166
167
# File 'lib/TNR360/components/lds_checkbox.rb', line 165

def getIdBlock
  @idBlock
end

#getIdentifierObject



162
163
164
# File 'lib/TNR360/components/lds_checkbox.rb', line 162

def getIdentifier
  @idField
end

#getIdScreenObject



168
169
170
# File 'lib/TNR360/components/lds_checkbox.rb', line 168

def getIdScreen
  @idScreen
end

#getLabelObject



179
180
181
# File 'lib/TNR360/components/lds_checkbox.rb', line 179

def getLabel
 @label
end

#getValueObject



175
176
177
# File 'lib/TNR360/components/lds_checkbox.rb', line 175

def getValue
 @value
end

#isCheckedObject



171
172
173
# File 'lib/TNR360/components/lds_checkbox.rb', line 171

def isChecked
 puts @checked
end

#isEditable?Boolean

Returns:

  • (Boolean)


187
188
189
# File 'lib/TNR360/components/lds_checkbox.rb', line 187

def isEditable?
@editable
end

#isExistObject



191
192
193
# File 'lib/TNR360/components/lds_checkbox.rb', line 191

def isExist
 @exists
end

#isScreenDisplayedObject



116
117
118
119
120
121
122
123
# File 'lib/TNR360/components/lds_checkbox.rb', line 116

def isScreenDisplayed
  if (@idScreen!=nil)
    @scr=LdsScreen.new(@browser, @idScreen)
    @scr.isVisible?
  else
    false
  end
end

#isVisible?Boolean

Returns:

  • (Boolean)


183
184
185
# File 'lib/TNR360/components/lds_checkbox.rb', line 183

def isVisible?
@visible
end

#refreshObject

refresh object status from browser



28
29
30
31
32
33
34
# File 'lib/TNR360/components/lds_checkbox.rb', line 28

def refresh
  #Look for element in browser
  @current_element= findElement @idField
  #update other data
  update
  @exists
end

#to_sObject

print object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/TNR360/components/lds_checkbox.rb', line 125

def to_s
  "\n***** CheckBox *****"+
   "\nId : "+no_null(@idField.to_s) +
   "\nIdBlock : "+ no_null(@IdBlock.to_s)+
   "\nIdScreen : "+ no_null(@IdScreen.to_s)  +
   "\nValue : "+  no_null(@value.to_s)+
   "\nLabel : "+  no_null(@label.to_s)+
   "\nVisible : "+  no_null(@visible.to_s)+
   "\nEditable : "+ no_null(@editable.to_s)+
   "\nExists : "+  no_null(@exists.to_s)+
   "\nNature : "+  no_null(@nature.to_s)+
    "\nChecked : "+ no_null(@checked.to_s)+
  "\n**********"
end

#uncheckObject



148
149
150
151
152
153
# File 'lib/TNR360/components/lds_checkbox.rb', line 148

def uncheck
  @browser.div(:id => @idField).checkbox(:index => 0).when_present.clear
  @checked=false
  @exists=true
  update
end