Top Level Namespace
Defined Under Namespace
Modules: Connection, IfdAutomation Classes: Assertion, Email
Instance Method Summary collapse
- #bind_with_dyn_json_vars(json, bind_json) ⇒ Object
-
#bind_with_dyn_vars(str) ⇒ Object
bind string with $dyn_vars context.
- #call_and_fail_gracefully(client, *args, &block) ⇒ Object
-
#check_alert_text(text) ⇒ Object
method to check javascript pop-up alert text.
- #check_dynamic_value(value) ⇒ Object
-
#check_title(title, test_case) ⇒ Object
Method to verify title param 1 : String : expected title param 2 : Boolean : test case [true or flase].
- #double_click(element) ⇒ Object
-
#eval_with_dyn_vars(operation) ⇒ Object
evaluate operation/statement with $dyn_vars context.
-
#execute_checkproperty(element, property, negate, value, isSpecialChar = false) ⇒ Object
Check object property.
-
#execute_click(element) ⇒ Object
Click on element.
- #execute_getproperty(element, property) ⇒ Object
-
#execute_gettext(element) ⇒ Object
Get text from web element.
-
#execute_openbrowser(url_site) ⇒ Object
Open Browser with config-able maximize browser option.
-
#execute_select(element, text) ⇒ Object
Select.
-
#execute_settext(element, text) ⇒ Object
Enter text to element.
-
#find_object(string_object) ⇒ Object
Find object by Xpath.
-
#find_object_check_object(cur_element, strId, strText) ⇒ Object
Find/Check the object by ID and Text.
-
#generate_xpath_selector(strId, strClass, strName, strTagname) ⇒ Object
Generate Xpath Selector.
-
#get_objects_by_XpathSelector(strXpathSelector) ⇒ Object
Get object by XpathSelector.
- #get_xpath_value_from_object_file(string_object) ⇒ Object
-
#maximize_browser ⇒ Object
Method to maximize browser.
-
#put_log(str) ⇒ Object
Print script log to console.
- #replace_day(str) ⇒ Object
- #replace_month(str) ⇒ Object
- #replace_pipe(str_pipe) ⇒ Object
- #replace_year(str) ⇒ Object
- #resolve_params(url) ⇒ Object
-
#scroll_page(to) ⇒ Object
method to scroll page to top or end.
-
#set_var(var_name, var_value) ⇒ Object
set value to a variable.
-
#switch_to_window_by_title(window_title) ⇒ Object
Method to switch to window by title.
- #var_collect(string_var) ⇒ Object
Instance Method Details
#bind_with_dyn_json_vars(json, bind_json) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/helper/auto_utils.rb', line 35 def bind_with_dyn_json_vars(json, bind_json) if json.kind_of? Hash json.each_pair do |k, v| if v.kind_of? String bind_json[bind_with_dyn_vars(k)] = bind_with_dyn_json_vars(v, bind_json) elsif v.kind_of? Hash temp = Hash.new v.each_pair do |k1, v1| temp[bind_with_dyn_vars(k1)] = bind_with_dyn_json_vars(v1, temp) end bind_json[bind_with_dyn_vars(k)] = temp elsif v.kind_of? Array temp1 = Array.new v.each {|item| temp2 = Hash.new bind_with_dyn_json_vars(item, temp2) temp1 << temp2 } bind_json[bind_with_dyn_vars(k)] = temp1 end end elsif json.kind_of? Array temp1 = Array.new json.each {|item| temp2 = Hash.new bind_with_dyn_json_vars(item, temp2) temp1 << temp2 } return temp1 else return bind_with_dyn_vars(json) end end |
#bind_with_dyn_vars(str) ⇒ Object
bind string with $dyn_vars context
17 18 19 20 21 22 23 24 |
# File 'lib/helper/auto_utils.rb', line 17 def bind_with_dyn_vars(str) if $dyn_vars == nil $dyn_vars = binding end strEval = '"' + str + '"' return eval strEval, $dyn_vars end |
#call_and_fail_gracefully(client, *args, &block) ⇒ Object
50 51 52 53 54 |
# File 'lib/Ifd_Automation/SOAP_steps.rb', line 50 def call_and_fail_gracefully(client, *args, &block) client.call(*args, &block) rescue Savon::SOAPFault => e puts e. end |
#check_alert_text(text) ⇒ Object
method to check javascript pop-up alert text
118 119 120 121 122 123 |
# File 'lib/helper/web_steps_helpers.rb', line 118 def check_alert_text(text) alert = page.driver.browser.switch_to.alert.text if alert != text raise "Text on alert pop up not matched, Actual Text : #{alert}, Expected Text : #{text}" end end |
#check_dynamic_value(value) ⇒ Object
1 2 3 4 5 6 7 |
# File 'lib/helper/core.rb', line 1 def check_dynamic_value value if value.include? "params=" resolve_params value else bind_with_dyn_vars value end end |
#check_title(title, test_case) ⇒ Object
Method to verify title param 1 : String : expected title param 2 : Boolean : test case [true or flase]
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/helper/web_steps_helpers.rb', line 104 def check_title(title, test_case) page_title = page.title if test_case if page_title != "#{title}" raise "Page Title Not Matched, Actual Page Title : #{page_title}, Expected Page Title : #{title}" end else if page_title == "#{title}" raise "Page Title Matched, Actual Page Title: #{page_title}" end end end |
#double_click(element) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/helper/web_steps_helpers.rb', line 38 def double_click(element) foundElement = find_object(element) if foundElement != nil begin page.driver.browser.action.double_click(foundElement.native) rescue StandardError => myStandardError raise "\n>>> Error: #{myStandardError}" end else raise "\nError >> Not found object: #{element}" exit end end |
#eval_with_dyn_vars(operation) ⇒ Object
evaluate operation/statement with $dyn_vars context
27 28 29 30 31 32 33 |
# File 'lib/helper/auto_utils.rb', line 27 def eval_with_dyn_vars(operation) if $dyn_vars == nil $dyn_vars = binding end eval operation, $dyn_vars end |
#execute_checkproperty(element, property, negate, value, isSpecialChar = false) ⇒ Object
Check object property
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/helper/core.rb', line 254 def execute_checkproperty element, property, negate, value, isSpecialChar=false .configure do |config| config.ignore_hidden_elements = false end foundElement = find_object(element) check = false if foundElement == nil and value == "" check = true # check.should eq true expect(check).to eq true else # put_log "\n\n\t>>> execute_checkproperty: finish to found element" if foundElement != nil if property.upcase == 'VALUE' actual_value = foundElement.value() elsif property.upcase == 'TEXT' actual_value = foundElement.text() elsif property.upcase == 'SPECIAL CHAR' actual_value = foundElement.text() isSpecialChar = true elsif property.upcase == 'TAGNAME' actual_value = foundElement.tag_name() elsif property.upcase == 'STYLE' actual_value = foundElement[:style] elsif property.upcase == 'DISABLED' actual_value = foundElement[:disabled] elsif property.upcase == 'WIDTH' actual_value = foundElement[:width] elsif property.upcase == 'HEIGHT' actual_value = foundElement[:height] elsif property.upcase == 'ID' actual_value = foundElement[:id] elsif property.upcase == 'NAME' actual_value = foundElement[:name] elsif property.upcase == 'CLASS' actual_value = foundElement[:class] elsif property.upcase == 'HREF' actual_value = foundElement[:href] elsif property.upcase == 'TITLE' actual_value = foundElement[:title] elsif property.upcase == 'TYPE' actual_value = foundElement[:type] elsif property.upcase == 'CHECKED' actual_value = "true" if foundElement.checked? == true actual_value = "false" if foundElement.checked? == false else actual_value = foundElement["#{property}"] end if actual_value == nil actual_value = '' end else put_log "\nError >> Not found object: #{element}" end .configure do |config| config.ignore_hidden_elements = true end if Assertion.reg_compare(actual_value, value, isSpecialChar) check = true end put_log "\n#{property} :: Actual result is: '#{actual_value}' -- Expected result is: '#{value}'" if negate == " not" # check.should_not eq true # expect(check).not_to eql true !Assertion.assert_string_not_equal(actual_value,value) elsif # check.should eq true # expect(check).to eq true Assertion.assert_string_equal(actual_value,value) end end end |
#execute_click(element) ⇒ Object
Click on element
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/helper/web_steps_helpers.rb', line 21 def execute_click element foundElement = find_object(element) if foundElement != nil page.driver.execute_script('window.focus();') startTime = Time.new.to_i begin sleep(0.5) currentTime = Time.new.to_i end while (foundElement.native.enabled? == false and (currentTime - startTime) < $_CFWEB['Wait Time']) page.driver.browser.execute_script("arguments[0].scrollIntoView(true);", foundElement.native) page.driver.browser.action.click(foundElement.native) foundElement.native.send_keys(:return) else raise "\nError >> Not found object: #{element}" end end |
#execute_getproperty(element, property) ⇒ Object
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/helper/core.rb', line 347 def execute_getproperty element, property .configure do |config| config.ignore_hidden_elements = false end foundElement = find_object(element) check = false if foundElement == nil and value == "" check = true # check.should eq true expect(check).to eq true else # put_log "\n\n\t>>> execute_getproperty: finish to found element" if foundElement != nil if property.upcase == 'VALUE' actual_value = foundElement.value() elsif property.upcase == 'TEXT' actual_value = foundElement.text() elsif property.upcase == 'TAGNAME' actual_value = foundElement.tag_name() elsif property.upcase == 'STYLE' actual_value = foundElement[:style] elsif property.upcase == 'DISABLED' actual_value = foundElement[:disabled] elsif property.upcase == 'WIDTH' actual_value = foundElement[:width] elsif property.upcase == 'HEIGHT' actual_value = foundElement[:height] elsif property.upcase == 'ID' actual_value = foundElement[:id] elsif property.upcase == 'NAME' actual_value = foundElement[:name] elsif property.upcase == 'CLASS' actual_value = foundElement[:class] elsif property.upcase == 'HREF' actual_value = foundElement[:href] elsif property.upcase == 'TITLE' actual_value = foundElement[:title] elsif property.upcase == 'TYPE' actual_value = foundElement[:type] else actual_value = foundElement["#{property}"] end if actual_value == nil actual_value = '' end else put_log "\nError >> Not found object: #{element}" end .configure do |config| config.ignore_hidden_elements = true end actual_value end end |
#execute_gettext(element) ⇒ Object
Get text from web element
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/helper/core.rb', line 418 def execute_gettext element foundElement = find_object(element) if foundElement != nil tagname = foundElement.tag_name() if tagname.upcase == 'SELECT' #@text = page.evaluate_script("$(\"##{foundElement[:id]}\").text()") else actual_text = foundElement.text() if (actual_text == nil or actual_text.length == 0) and (tagname.upcase == 'INPUT' or tagname.upcase == 'TEXTAREA') actual_text = foundElement.value() end end put_log "\nText is '" + actual_text + "' of object '" + element + "'" $context_value = actual_text else put_log "\nError >> Not found object: #{element}" exit end end |
#execute_openbrowser(url_site) ⇒ Object
Open Browser with config-able maximize browser option
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/helper/web_steps_helpers.rb', line 4 def execute_openbrowser url_site #, redirect begin if $_CFWEB['Maximize Browser'] == true page.driver.browser.manage.window.maximize end rescue StandardError => myStandardError raise "\n>>> Error: #{myStandardError}" end if url_site == "" raise "\n>>> Error: Null web page URL." else visit(url_site) end end |
#execute_select(element, text) ⇒ Object
Select
496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/helper/core.rb', line 496 def execute_select element, text #select(text, :xpath => element) foundElement = find_object(element) if foundElement != nil option_value = page.evaluate_script("$(\"##{foundElement[:id]} option:contains('#{text}')\").val()") page.execute_script("$('##{foundElement[:id]}').val('#{option_value}')") page.execute_script("$('##{foundElement[:id]}').trigger('liszt:updated').trigger('change')") else put_log "\nError >> Not found object: #{element}" exit end end |
#execute_settext(element, text) ⇒ Object
Enter text to element
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/helper/web_steps_helpers.rb', line 53 def execute_settext element, text foundElement = find_object(element) if foundElement != nil begin foundElement.set(text) rescue StandardError => myStandardError raise "\n>>> Error: #{myStandardError}" end else raise "\nError >> Not found object: #{element}" exit end end |
#find_object(string_object) ⇒ Object
Find object by Xpath
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/helper/core.rb', line 76 def find_object string_object startTime = Time.new.to_i string_object = string_object.gsub(/"/, "'") locator_matching = /(.*?)(\{.*?\})/.match(string_object) dyn_pros = {} if locator_matching != nil string_object = locator_matching[1] eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v| dyn_pros[k.to_s.upcase] = v } end hash_object = $OBJECT[string_object] if hash_object == nil put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!" # true.should eq false expect(true).to eq(false) end upcase_attrb = {} if hash_object != nil hash_object.each { |k, v| k = k.to_s.upcase # put_log "\n#{k} =~ /ph_/i and dyn_pros[#{k}]: #{k =~ /ph_/i and dyn_pros[k] != nil}" if k =~ /ph_/i if dyn_pros[k] != nil # Assign place holder value to place holder property, also remove prefix ph_ from property key, # also remove this pl from dyn_pros <= should be consider to continue transfer into inner object in relation if v =~ /<ph_value>/i upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k]) else upcase_attrb[k[3..k.size-1]] = dyn_pros[k] end dyn_pros.delete(k) end else upcase_attrb[k.to_s.upcase] = v end } end if upcase_attrb.size > 0 strId = "" strClass = "" strName = "" strTagname = "" strXpathSelector = "" strText = "" index = nil upcase_attrb.each { |key, value| upcase_key = key.to_s.upcase if upcase_key == "XPATH_SELECTOR" strXpathSelector = value end } continue_run = true if continue_run == true begin if strXpathSelector != nil and strXpathSelector.size > 0 foundElements = get_objects_by_XpathSelector(strXpathSelector) else #Generate Selector strGenerateXpathSel = "" strGenerateXpathSel = generate_xpath_selector(strId, strClass, strName, strTagname) if strGenerateXpathSel.length > 0 foundElements = get_objects_by_XpathSelector(strGenerateXpathSel) end end if foundElements == nil or foundElements.size == 0 currentTime = Time.new.to_i else # put_log "\nBREAK!!!" break end test = currentTime - startTime # put_log "\n#TIMEOUNT:#{test} < #{$_CFWEB['Wait Time']}" sleep(0.5) end while (currentTime - startTime) < $_CFWEB['Wait Time'] if foundElements != nil or foundElements.size != 0 if index != nil and index.to_i >= 0 matched_index = 0; return_element = nil foundElements.each { |cur_element| passCheck = find_object_check_object(cur_element, strId, strText) if passCheck if matched_index == index.to_i return_element = cur_element break else matched_index = matched_index + 1 end end } return return_element else return_element = nil foundElements.each { |cur_element| passCheck = find_object_check_object(cur_element, strId, strText) if passCheck return_element = cur_element break end } return return_element end # if index != nil and index.to_i >= 0 end #if foundElements != nil or foundElements.length != 0 end #if continue = true end return nil end |
#find_object_check_object(cur_element, strId, strText) ⇒ Object
Find/Check the object by ID and Text
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/helper/core.rb', line 230 def find_object_check_object cur_element, strId, strText passCheck = true if cur_element != nil # Check ID if strId != nil and strId.length > 0 if strId =~ /^#/ strId = strId[1..-1] end end # Check Text if passCheck and strText != nil and strText.length > 0 if (strText =~ /^#/) strText = strText[1..-1] end end return passCheck end return false end |
#generate_xpath_selector(strId, strClass, strName, strTagname) ⇒ Object
Generate Xpath Selector
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/helper/core.rb', line 193 def generate_xpath_selector(strId, strClass, strName, strTagname) strGenerateXpathSel = "" if strId != nil and strId.length > 0 and (strId =~ /^#/) == nil strGenerateXpathSel = "[@id='#{strId}']" end if strClass != nil and strClass.length > 0 and (strClass =~ /^#/) == nil strGenerateXpathSel = "#{strGenerateXpathSel}[@class='#{strClass}']" end if strName != nil and strName.length > 0 and (strName =~ /^#/) == nil strGenerateXpathSel = "#{strGenerateXpathSel}[@name='#{strName}']" end if strGenerateXpathSel.length > 0 if strTagname != nil and strTagname.length > 0 strGenerateXpathSel = "//#{strTagname}#{strGenerateXpathSel}" else strGenerateXpathSel = "//*#{strGenerateXpathSel}" end end return strGenerateXpathSel end |
#get_objects_by_XpathSelector(strXpathSelector) ⇒ Object
Get object by XpathSelector
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/helper/core.rb', line 217 def get_objects_by_XpathSelector(strXpathSelector) # put_log "\nstrXpathSelector: #{strXpathSelector}" foundElements = nil begin foundElements = page.all(:xpath, strXpathSelector) rescue StandardError => myStandardError put_log "\n>>> Error: #{myStandardError}" end return foundElements end |
#get_xpath_value_from_object_file(string_object) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/helper/core.rb', line 30 def get_xpath_value_from_object_file string_object string_object = string_object.gsub(/"/, "'") # puts "String_object: #{string_object}" locator_matching = /(.*?)(\{.*?\})/.match(string_object) # puts "locator_matching : #{locator_matching}" dyn_pros = {} if locator_matching != nil string_object = locator_matching[1] eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v| dyn_pros[k.to_s.upcase] = v } end hash_object = $OBJECT[string_object] if hash_object == nil put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!" # true.should eq false expect(true).to eq(false) end xpath_value = "" upcase_attrb = {} if hash_object != nil hash_object.each { |k, v| k = k.to_s.upcase # put_log "\n#{k} =~ /ph_/i and dyn_pros[#{k}]: #{k =~ /ph_/i and dyn_pros[k] != nil}" if k =~ /ph_/i if dyn_pros[k] != nil # Assign place holder value to place holder property, also remove prefix ph_ from property key, # also remove this pl from dyn_pros <= should be consider to continue transfer into inner object in relation if v =~ /<ph_value>/i upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k]) else upcase_attrb[k[3..k.size-1]] = dyn_pros[k] end dyn_pros.delete(k) end else upcase_attrb[k.to_s.upcase] = v end xpath_value = v } end xpath_value end |
#maximize_browser ⇒ Object
Method to maximize browser
68 69 70 |
# File 'lib/helper/web_steps_helpers.rb', line 68 def maximize_browser page.driver.browser.manage.window.maximize end |
#put_log(str) ⇒ Object
Print script log to console
25 26 27 |
# File 'lib/helper/core.rb', line 25 def put_log str puts str if $_CFWEB['Print Log'] == true end |
#replace_day(str) ⇒ Object
476 477 478 479 480 481 482 483 484 485 |
# File 'lib/helper/core.rb', line 476 def replace_day str t = Time.now() _day = t.day if _day < 10 return str.gsub("{day}", "0#{_day.to_s}") else return str.gsub("{day}", "#{_day.to_s}") end return str end |
#replace_month(str) ⇒ Object
465 466 467 468 469 470 471 472 473 474 |
# File 'lib/helper/core.rb', line 465 def replace_month str t = Time.now() _month = t.month if _month < 10 return str.gsub("{month}", "0#{_month.to_s}") else return str.gsub("{month}", "#{_month.to_s}") end return str end |
#replace_pipe(str_pipe) ⇒ Object
487 488 489 490 491 492 493 |
# File 'lib/helper/core.rb', line 487 def replace_pipe str_pipe put_log ">>>> #{str_pipe}" if str_pipe =~ /^.*{pipe}.*$/ return str_pipe.gsub("{pipe}", "|") end return str_pipe end |
#replace_year(str) ⇒ Object
460 461 462 463 |
# File 'lib/helper/core.rb', line 460 def replace_year str t = Time.now() return str.gsub("{year}", t.year.to_s) end |
#resolve_params(url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/helper/core.rb', line 10 def resolve_params url condition = url.match(/params='([^']*)'/)[0] if condition params_name = url.match(/params='([^']*)'/)[1] params_value = $PARAMS["#{params_name.downcase}"] if params_value url = url.gsub(condition, params_value) else raise "ERROR: no data found with given params #{params_name}" end end url end |
#scroll_page(to) ⇒ Object
method to scroll page to top or end
87 88 89 90 91 92 93 94 95 |
# File 'lib/helper/web_steps_helpers.rb', line 87 def scroll_page(to) if to == 'end' page.driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));') elsif to == 'top' page.driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);') else raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")" end end |
#set_var(var_name, var_value) ⇒ Object
set value to a variable
7 8 9 10 11 12 13 14 |
# File 'lib/helper/auto_utils.rb', line 7 def set_var(var_name, var_value) if $dyn_vars == nil $dyn_vars = binding end strEval = var_name + "=" + var_value eval strEval, $dyn_vars end |
#switch_to_window_by_title(window_title) ⇒ Object
Method to switch to window by title
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/helper/web_steps_helpers.rb', line 73 def switch_to_window_by_title window_title $previous_window = page.driver.browser.window_handle window_found = false page.driver.browser.window_handles.each{ |handle| page.driver.browser.switch_to.window handle if page.title == window_title window_found = true break end } raise "Window having title \"#{window_title}\" not found" if not window_found end |
#var_collect(string_var) ⇒ Object
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/helper/core.rb', line 440 def var_collect string_var if string_var =~ /^.*{year}.*$/ string_var = replace_year(string_var) end if string_var =~ /^.*{month}.*$/ string_var = replace_month(string_var) end if string_var =~ /^.*{day}.*$/ string_var = replace_day(string_var) end if string_var =~ /^.*{store_value}.*$/ string_var = $context_value end return string_var end |