Class: LdsTextField

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

Direct Known Subclasses

LdsFKey, LdsLov

Instance Method Summary collapse

Constructor Details

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

constructor



21
22
23
24
25
26
27
28
# File 'lib/TNR360/components/lds_text_field.rb', line 21

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

Instance Method Details

#fill(value) ⇒ Object

LdsScreen Actions



150
151
152
153
# File 'lib/TNR360/components/lds_text_field.rb', line 150

def fill (value)
  @browser.text_field(:id => @idField).when_present.set(value)
  update
end

#findElement(idElement) ⇒ Object

method locate current element



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

def findElement idElement
  @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 'Element found = '+@exists.to_s


  if (@browser.text_fields(:id => idElement).length>1 && @idBlock!=nil)
    #utiliser le id bloc
    @bloc=LdsBlock.new(@browser, @idBlock)
    @current_element=@bloc.getElement.text_field(:id, idElement).when_present
  else
    if (@browser.text_fields(:id => idElement).length>1)
      @browser.text_fields(:id => idElement).each do |field|
        if field.visible?
          @current_element=field
          break
        end
      end
    else
      @current_element=@browser.text_field(:id, idElement).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_text_field.rb', line 158

def getElement
  @current_element
end

#getIdBlockObject



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

def getIdBlock
  @idBlock
end

#getIdentifierObject



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

def getIdentifier
  @idField
end

#getIdScreenObject



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

def getIdScreen
  @idScreen
end

#getLabelObject



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

def getLabel
  @label
end

#getValueObject



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

def getValue
  @value
end

#isEditable?Boolean

Returns:

  • (Boolean)


190
191
192
# File 'lib/TNR360/components/lds_text_field.rb', line 190

def isEditable?
  @editable
end

#isExist?Boolean

Returns:

  • (Boolean)


194
195
196
# File 'lib/TNR360/components/lds_text_field.rb', line 194

def isExist?
  @exists
end

#isMandatory?Boolean

Returns:

  • (Boolean)


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

def isMandatory?
  @mandatory
end

#isScreenDisplayedObject



98
99
100
101
102
103
104
105
# File 'lib/TNR360/components/lds_text_field.rb', line 98

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

#isVisible?Boolean

Returns:

  • (Boolean)


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

def isVisible?
  @visible
end

#refreshObject

refresh object status from browser



31
32
33
34
35
36
37
# File 'lib/TNR360/components/lds_text_field.rb', line 31

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

#to_sObject

print object



134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/TNR360/components/lds_text_field.rb', line 134

def to_s
  "\n***** Text_Field *****"+
      "\nId : "+no_null(@idField) +
      "\nIdBlock : "+ no_null(@IdBlock)+
      "\nIdScreen : "+ no_null(@IdScreen) +
      "\nValue : "+ no_null(@value)+
      "\nLabel : "+ no_null(@label)+
      "\nMandatory : "+ no_null(@mandatory.to_s)+
      "\nVisible : "+ no_null(@visible.to_s)+
      "\nEditable : "+ no_null(@editable.to_s)+
      "\nExists : "+ no_null(@exists.to_s)+
      "\n**********"
end