Class: LdsCheckbox
- Inherits:
-
Object
- Object
- LdsCheckbox
- Defined in:
- lib/TNR360/components/lds_checkbox.rb
Instance Method Summary collapse
-
#check ⇒ Object
LdsScreen Actions.
- #elementExists?(idElement) ⇒ Boolean
-
#findElement(idElement) ⇒ Object
method locate current element.
-
#getElement ⇒ Object
Getters.
- #getIdBlock ⇒ Object
- #getIdentifier ⇒ Object
- #getIdScreen ⇒ Object
- #getLabel ⇒ Object
- #getValue ⇒ Object
-
#initialize(browser, idField, idBlock = nil, idScreen = nil) ⇒ LdsCheckbox
constructor
constructor.
- #isChecked ⇒ Object
- #isEditable? ⇒ Boolean
- #isExist ⇒ Object
- #isScreenDisplayed ⇒ Object
- #isVisible? ⇒ Boolean
-
#refresh ⇒ Object
refresh object status from browser.
-
#to_s ⇒ Object
print object.
- #uncheck ⇒ Object
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
#check ⇒ Object
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
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 |
#getElement ⇒ Object
Getters
158 159 160 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 158 def getElement @current_element end |
#getIdBlock ⇒ Object
165 166 167 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 165 def getIdBlock @idBlock end |
#getIdentifier ⇒ Object
162 163 164 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 162 def getIdentifier @idField end |
#getIdScreen ⇒ Object
168 169 170 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 168 def getIdScreen @idScreen end |
#getLabel ⇒ Object
179 180 181 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 179 def getLabel @label end |
#getValue ⇒ Object
175 176 177 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 175 def getValue @value end |
#isChecked ⇒ Object
171 172 173 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 171 def isChecked puts @checked end |
#isEditable? ⇒ Boolean
187 188 189 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 187 def isEditable? @editable end |
#isExist ⇒ Object
191 192 193 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 191 def isExist @exists end |
#isScreenDisplayed ⇒ Object
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
183 184 185 |
# File 'lib/TNR360/components/lds_checkbox.rb', line 183 def isVisible? @visible end |
#refresh ⇒ Object
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_s ⇒ Object
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 |
#uncheck ⇒ Object
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 |