Class: LdsRadio

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

Instance Method Summary collapse

Constructor Details

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

constructor



15
16
17
18
19
20
21
22
# File 'lib/TNR360/components/lds_radio.rb', line 15

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



143
144
145
146
147
148
149
# File 'lib/TNR360/components/lds_radio.rb', line 143

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

#elementExists?(idElement) ⇒ Boolean

Returns:

  • (Boolean)


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

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).radio(:index => 0).exists?)
    @browser.div(:id => idElement).radio(: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).radio(:index => 0).when_present(10)
        oneIsVisible=true
      end
    end
  end
  oneIsVisible
end

#findElement(idElement) ⇒ Object

method locate current element



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

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 'Radio 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).radio(: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.radio(:index => 0)
          break
        end
      end
    else
      @current_element=@browser.div(:id => idElement).radio(: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



153
154
155
# File 'lib/TNR360/components/lds_radio.rb', line 153

def getElement
  @current_element
end

#getIdBlockObject



160
161
162
# File 'lib/TNR360/components/lds_radio.rb', line 160

def getIdBlock
  @idBlock
end

#getIdentifierObject



157
158
159
# File 'lib/TNR360/components/lds_radio.rb', line 157

def getIdentifier
  @idField
end

#getIdScreenObject



163
164
165
# File 'lib/TNR360/components/lds_radio.rb', line 163

def getIdScreen
  @idScreen
end

#getLabelObject



174
175
176
# File 'lib/TNR360/components/lds_radio.rb', line 174

def getLabel
 @label
end

#getValueObject



170
171
172
# File 'lib/TNR360/components/lds_radio.rb', line 170

def getValue
  @value
end

#isCheckedObject



166
167
168
# File 'lib/TNR360/components/lds_radio.rb', line 166

def isChecked
  puts @checked
end

#isEditable?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'lib/TNR360/components/lds_radio.rb', line 182

def isEditable?
 @editable
end

#isExistObject



186
187
188
# File 'lib/TNR360/components/lds_radio.rb', line 186

def isExist
  @exists
end

#isScreenDisplayedObject



118
119
120
121
122
123
124
125
# File 'lib/TNR360/components/lds_radio.rb', line 118

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

#isVisible?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/TNR360/components/lds_radio.rb', line 178

def isVisible?
@visible
end

#refreshObject

refresh object status from browser



25
26
27
28
29
30
31
# File 'lib/TNR360/components/lds_radio.rb', line 25

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

#to_sObject

print object



128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/TNR360/components/lds_radio.rb', line 128

def to_s
  "\n***** Radio *****"+
      "\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)+
      "\nChecked : "+  no_null(@checked.to_s)+
      "\n**********"
end