class LdsRadio
Public Class Methods
new(browser,idField,idBlock=nil,idScreen=nil)
click to toggle source
constructor
# 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
Public Instance Methods
check()
click to toggle source
LdsScreen
Actions
# 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)
click to toggle source
# 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)
click to toggle source
method locate current element
# 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
getElement()
click to toggle source
Getters
# File lib/TNR360/components/lds_radio.rb, line 153 def getElement @current_element end
getIdBlock()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 160 def getIdBlock @idBlock end
getIdScreen()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 163 def getIdScreen @idScreen end
getIdentifier()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 157 def getIdentifier @idField end
getLabel()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 174 def getLabel @label end
getValue()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 170 def getValue @value end
isChecked()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 166 def isChecked puts @checked end
isEditable?()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 182 def isEditable? @editable end
isExist()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 186 def isExist @exists end
isScreenDisplayed()
click to toggle source
# 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?()
click to toggle source
# File lib/TNR360/components/lds_radio.rb, line 178 def isVisible? @visible end
refresh()
click to toggle source
refresh object status from browser
# 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_s()
click to toggle source
print object
# 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
Private Instance Methods
update()
click to toggle source
private method to update/save the status of the object
# File lib/TNR360/components/lds_radio.rb, line 34 def update @exists=false #Look for element in browser @current_element||= findElement @idField #fill label @label=@browser.label(:xpath => "//label[contains(@for,'"+@idField+"')]").when_present.text @checked= @current_element.set? @value=@current_element.set? #fill visible @visible=@current_element.visible? #fill editable @editable=!(@current_element.readonly?) #everything exists @exists=true end