Top Level Namespace
Defined Under Namespace
Modules: IfdAutomation
Instance Method Summary collapse
- #accept_alert ⇒ Object
- #assert_string_contain(expected, actual) ⇒ Object
- #assert_string_equal(expected, actual) ⇒ Object
- #assert_string_not_equal(expected, actual) ⇒ Object
- #back ⇒ Object
- #bind_with_dyn_json_vars(json, bind_json) ⇒ Object
-
#bind_with_dyn_vars(str) ⇒ Object
bind string with $dyn_vars context.
- #check_dynamic_value(value) ⇒ Object
- #check_string_letters_only(strToCheck) ⇒ Object
- #check_valid_keys?(key) ⇒ Boolean
- #check_valid_option_by?(option_by) ⇒ Boolean
- #clear_text(element) ⇒ Object
- #close_windows ⇒ Object
-
#do_assertion_csv_tab_non_order(expected_obj, actual_obj) ⇒ Object
Assert two files, rows not in order and REMOVE 1 COLUMN OF ID.
- #do_assertion_json(expected_obj, actual_obj, options = {}) ⇒ Object
- #double_click(element) ⇒ Object
- #drag_and_drop_by_offset(element, x, y) ⇒ Object
- #drag_and_drop_to_object(from_element, element) ⇒ Object
-
#eval_with_dyn_vars(operation) ⇒ Object
evaluate operation/statement with $dyn_vars context.
- #execute_checkproperty(element, property, negate, value, isSpecialChar = false) ⇒ Object
- #execute_click(element) ⇒ Object
- #execute_click_offset(element, x, y) ⇒ Object
- #execute_javascript(script) ⇒ Object
- #execute_mouse_over(element) ⇒ Object
- #execute_openbrowser(url_site) ⇒ Object
- #execute_select(element, text) ⇒ Object
- #execute_sendkeys(element, key) ⇒ Object
-
#execute_setstate(element, state) ⇒ Object
Set state.
- #execute_settext(element, text) ⇒ Object
- #find_object(string_object) ⇒ Object
- #find_object_check_Class(element, strClass) ⇒ Object
- #find_object_check_Id(element, strId) ⇒ Object
- #find_object_check_maxHeight(element, maxHeight) ⇒ Object
- #find_object_check_maxWidth(element, maxWidth) ⇒ Object
- #find_object_check_minHeight(element, minHeight) ⇒ Object
- #find_object_check_minWidth(element, minWidth) ⇒ Object
- #find_object_check_Name(element, strName) ⇒ Object
- #find_object_check_object(cur_element, ref_object, ref_object_type, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros) ⇒ Object
- #find_object_check_ref_object(ref_object, ref_type, target_element) ⇒ Object
- #find_object_check_Tagname(element, strTagname) ⇒ Object
- #find_object_check_Text(element, strText) ⇒ Object
- #find_object_check_Xpath(element, strXpath) ⇒ Object
- #generate_xpath_selector(strId, strClass, strName, strTagname) ⇒ Object
- #get_computed_style(element, style) ⇒ Object
- #get_element_attribute(element, value) ⇒ Object
- #get_element_text(element) ⇒ Object
- #get_object_and_store_as_string(object, string) ⇒ Object
- #get_object_and_store_to_file(object, file_name) ⇒ Object
- #get_object_value(str_obj) ⇒ Object
- #get_objects_by_Class(strClass) ⇒ Object
- #get_objects_by_css_selector(strCssSelector) ⇒ Object
- #get_objects_by_Id(strId) ⇒ Object
- #get_objects_by_Name(strName) ⇒ Object
- #get_objects_by_Tagname(strTagname) ⇒ Object
- #get_objects_by_xpath_selector(strXpathSelector) ⇒ Object
- #maximize_browser ⇒ Object
- #movemouseandclick(var, element) ⇒ Object
- #print_variable(variable) ⇒ Object
- #put_log(str) ⇒ Object
- #refresh ⇒ Object
-
#reg_compare(sActual, regValue, isSpecialChar = false) ⇒ Object
Assert 2 values.
- #remove_element_attribute(element, attr) ⇒ Object
- #replace_day(str) ⇒ Object
- #replace_month(str) ⇒ Object
- #replace_pipe(str_pipe) ⇒ Object
- #replace_year(str) ⇒ Object
- #resize_window_screen(x, y) ⇒ Object
- #resolve_params(url) ⇒ Object
- #scroll_to_end_page ⇒ Object
- #scroll_to_top_page ⇒ Object
-
#set_var(var_name, var_value) ⇒ Object
set value to a variable.
- #store_string_as_variable(string, variable) ⇒ Object
- #switch_to_frame(element) ⇒ Object
- #switch_to_window_by_title(window_title) ⇒ Object
- #validate_option_by(option_by) ⇒ Object
- #validate_supported_keys(key) ⇒ Object
- #var_collect(string_var) ⇒ Object
- #verify_alert_text(text) ⇒ Object
- #verify_element_not_has_text(element, value) ⇒ Object
- #verify_element_not_has_value(element, value) ⇒ Object
- #verify_element_text(element, value) ⇒ Object
- #verify_element_value(element, value) ⇒ Object
- #verify_title(expected_title) ⇒ Object
Instance Method Details
#accept_alert ⇒ Object
143 144 145 146 147 148 149 150 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 143 def accept_alert begin page.driver.browser.switch_to.alert.accept rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end end |
#assert_string_contain(expected, actual) ⇒ Object
81 82 83 84 85 |
# File 'lib/Ifd_Automation/assertion_helper.rb', line 81 def assert_string_contain(expected, actual) unless (actual.to_s).include? (expected.to_s) raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.") end end |
#assert_string_equal(expected, actual) ⇒ Object
87 88 89 90 91 |
# File 'lib/Ifd_Automation/assertion_helper.rb', line 87 def assert_string_equal(expected, actual) if expected.to_s != actual.to_s raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.") end end |
#assert_string_not_equal(expected, actual) ⇒ Object
93 94 95 96 97 |
# File 'lib/Ifd_Automation/assertion_helper.rb', line 93 def assert_string_not_equal(expected, actual) if expected.to_s == actual.to_s raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.") end end |
#back ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 152 def back begin page.execute_script('window.history.back()') rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end end |
#bind_with_dyn_json_vars(json, bind_json) ⇒ Object
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 |
# File 'lib/Ifd_Automation/auto_util.rb', line 62 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
44 45 46 47 48 49 50 51 |
# File 'lib/Ifd_Automation/auto_util.rb', line 44 def bind_with_dyn_vars(str) if $dyn_vars == nil $dyn_vars = binding end strEval = '"' + str + '"' return eval strEval, $dyn_vars end |
#check_dynamic_value(value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/Ifd_Automation/auto_util.rb', line 16 def check_dynamic_value value if !value.is_a? Fixnum if value.include? "params=" resolve_params value else bind_with_dyn_vars value end else value end end |
#check_string_letters_only(strToCheck) ⇒ Object
669 670 671 672 673 674 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 669 def check_string_letters_only(strToCheck) if strToCheck != nil and strToCheck.length > 0 and strToCheck =~ /^[a-zA-Z]+$/ return true end return false end |
#check_valid_keys?(key) ⇒ Boolean
479 480 481 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 479 def check_valid_keys?(key) %w(:cancel :help :backspace :tab :clear :return :enter :shift :control :alt :pause :escape :space :page_up :page_down :end :home :left :up :right :down :insert :delete :semicolon :equals).include? key end |
#check_valid_option_by?(option_by) ⇒ Boolean
471 472 473 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 471 def check_valid_option_by?(option_by) %w(text value).include? option_by end |
#clear_text(element) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 170 def clear_text(element) foundElement = find_object(element) if foundElement != nil? begin foundElement.native.clear rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#close_windows ⇒ Object
259 260 261 262 263 264 265 266 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 259 def close_windows begin page.execute_script "window.close();" rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |
#do_assertion_csv_tab_non_order(expected_obj, actual_obj) ⇒ Object
Assert two files, rows not in order and REMOVE 1 COLUMN OF ID
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/Ifd_Automation/assertion_helper.rb', line 2 def do_assertion_csv_tab_non_order(expected_obj, actual_obj) for i in (1..expected_obj.length - 1) expected_row = expected_obj[i].drop(1).to_s.split("\t") found = false for j in (1..actual_obj.length - 1) actual_row = actual_obj[j].drop(1).to_s.split("\t") if (expected_row == actual_row) found = true break end end assert(found, "Expected Record: [#{expected_obj[i].to_s}] is not included in reporting file") end end |
#do_assertion_json(expected_obj, actual_obj, options = {}) ⇒ Object
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 74 75 76 77 78 79 |
# File 'lib/Ifd_Automation/assertion_helper.rb', line 47 def do_assertion_json(expected_obj, actual_obj, = {}) # puts "\n\n actual_obj.class: #{actual_obj.class}" # puts "\n\n expected_obj.class: #{expected_obj.class}" if expected_obj.kind_of? Hash # if options['isIncludedAssertion'].nil? or options['isIncludedAssertion'] == false # do_assertion(expected_obj.keys.size, actual_obj.keys.size) # end expected_obj.keys.each do |key| # puts "\n\n key: #{key}" # puts "\n\n value: #{expected_obj[key]}" # puts "\n\n value: #{actual_obj[key]}" if actual_obj[key].nil? raise "[%s] expected [%s] but actual value was nil." % [key, expected_obj[key].to_s] else do_assertion_json(expected_obj[key], actual_obj[key], ) end end elsif expected_obj.kind_of? Array if ['isIncludedAssertion'].nil? or ['isIncludedAssertion'] == false do_assertion_json(expected_obj.size, actual_obj.size) end for i in (0..expected_obj.length-1) do_assertion_json(expected_obj[i], actual_obj[i], ) end else begin assert_string_equal(expected_obj.to_s, actual_obj.to_s) rescue => e raise("Assert fail. \n\n Expected: '#{expected_obj}' \n\n Got: '#{actual_obj}'. Detail info: #{e.}") end end end |
#double_click(element) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 49 def double_click(element) foundElement = find_object(element) if foundElement != nil begin foundElement.double_click rescue StandardError => e puts "❌ Error: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#drag_and_drop_by_offset(element, x, y) ⇒ Object
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 1004 def drag_and_drop_by_offset(element, x, y) foundElement = find_object(element) if foundElement != nil begin page.driver.browser.action.drag_and_drop_by(foundElement, x, y).perform rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#drag_and_drop_to_object(from_element, element) ⇒ Object
1019 1020 1021 1022 1023 1024 1025 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 1019 def drag_and_drop_to_object(from_element, element) found_from_element = find_object(from_element) foundElement = find_object(element) if foundElement != nil and found_from_element != nil found_from_element.drag_to(foundElement) end end |
#eval_with_dyn_vars(operation) ⇒ Object
evaluate operation/statement with $dyn_vars context
54 55 56 57 58 59 60 |
# File 'lib/Ifd_Automation/auto_util.rb', line 54 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
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 419 def execute_checkproperty(element, property, negate, value, isSpecialChar=false) validate_option_by(property) Capybara.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() else actual_value = foundElement["#{property}"] end if actual_value == nil actual_value = '' end else put_log "❌ Error: Not found object: #{element}" end Capybara.configure do |config| config.ignore_hidden_elements = true end # if IFD_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" actual_value.should_not eq value expect(actual_value).not_to eql value elsif actual_value.should eq value expect(actual_value).to eq value end end end |
#execute_click(element) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 18 def execute_click(element) foundElement = find_object(element) if foundElement != nil begin foundElement.click rescue StandardError => e puts "❌ Error: #{e}" exit(1) end else puts "❌ Error >> Not found object: #{element}" exit(1) end end |
#execute_click_offset(element, x, y) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 33 def execute_click_offset(element, x, y) foundElement = find_object(element) if foundElement != nil begin page.driver.browser.mouse.move_to(foundElement.native,x.to_i,y.to_i) page.driver.browser.mouse.click() rescue Exception => e puts "❌ Error: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#execute_javascript(script) ⇒ Object
185 186 187 188 189 190 191 192 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 185 def execute_javascript(script) begin page.execute_script(script) rescue Exception => e puts "❌ Error: Not found object: #{element}" exit(1) end end |
#execute_mouse_over(element) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 212 def execute_mouse_over(element) foundElement = find_object(element) if foundElement != nil begin page.driver.browser.action.move_to(foundElement.native, element).click.perform sleep(1) rescue StandardError => e puts "❌ Error: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#execute_openbrowser(url_site) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 5 def execute_openbrowser(url_site) begin if url_site == "" puts "❌ Error: Null web page URL." exit(1) end visit(url_site) rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |
#execute_select(element, text) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 194 def execute_select(element, text) #select(text, :xpath => element) foundElement = find_object(element) if foundElement != nil begin 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')") rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#execute_sendkeys(element, key) ⇒ Object
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 1027 def execute_sendkeys(element, key) validate_supported_keys(key) foundElement = find_object(element) if foundElement != nil begin foundElement.native.send_keys(key) rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#execute_setstate(element, state) ⇒ Object
Set state
245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 245 def execute_setstate(element, state) foundElement = find_object(element) if foundElement != nil if state foundElement.select_option else foundElement.unselect_option end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#execute_settext(element, text) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 64 def execute_settext(element, text) foundElement = find_object(element) if foundElement != nil begin foundElement.set(text) rescue StandardError => e puts "❌ Error: #{e}" end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#find_object(string_object) ⇒ Object
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 487 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 puts "❌ ERROR: >>> Object: #{string_object} is not found in Object Repository." exit(1) end upcase_attrb = {} if hash_object != nil hash_object.each {|k,v| k = k.to_s.upcase if k =~ /ph_/i if dyn_pros[k] != nil 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 ph_attrs = {} dyn_pros.each{|k,v| if k =~ /ph_/i ph_attrs[k] = v else upcase_attrb[k.to_s.upcase] = v end } if upcase_attrb.size > 0 strId = "" strClass = "" strName = "" strTagname = "" strCssSelector = "" strXpathSelector = "" strText = "" = "" = "" index = nil minWidth = -1 maxWidth = -1 minHeight = -1 maxHeight = -1 ano_pros = {} upcase_attrb.each{|key, value| upcase_key = key.to_s.upcase case upcase_key when "XPATH_SELECTOR" strXpathSelector = value when "CSS_SELECTOR" strCssSelector = value when "ID" strId = value when "CLASS" strClass = value when "NAME" strName = value when "TAGNAME" strTagname = value when "TEXT" strText = value when "INDEX" index = value else raise "ERROR: >>> Wrong format type: #{key.to_s} of object: #{string_object}. Available supported format are: XPATH_SELECTOR | CSS_SELECTOR | ID | NAME | CLASS | TEXT | TAGNAME | INDEX" end } continue_run = true; ref_object = nil; if != nil and .length > 0 ref_object = find_object() if (ref_object == nil) continue_run = false end end if continue_run == true begin if strCssSelector != nil and strCssSelector.length > 0 foundElements = get_objects_by_css_selector(strCssSelector) elsif strXpathSelector != nil and strXpathSelector.length > 0 foundElements = get_objects_by_xpath_selector(strXpathSelector) else strGenerateXpathSel = generate_xpath_selector(strId, strClass, strName, strTagname) if strGenerateXpathSel.length > 0 foundElements = get_objects_by_xpath_selector(strGenerateXpathSel) else if (check_string_letters_only(strId)) foundElements = get_objects_by_Id(strId) elsif (check_string_letters_only(strName)) foundElements = get_objects_by_Name(strName) elsif (check_string_letters_only(strClass)) foundElements = get_objects_by_Class(strClass) elsif (check_string_letters_only(strTagname)) foundElements = get_objects_by_Tagname(strTagname) end end end if foundElements == nil or foundElements.length == 0 currentTime = Time.new.to_i else break end test = currentTime - startTime puts "\n Finding the object #{string_object}... TIME-OUT:: #{test} < #{$wait_time}" sleep(0.5) end while (currentTime - startTime) < $wait_time if foundElements != nil or foundElements.length != 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, ref_object, , strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros) 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, ref_object, , strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros) 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_Class(element, strClass) ⇒ Object
856 857 858 859 860 861 862 863 864 865 866 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 856 def find_object_check_Class(element, strClass) actual_Class = element[:class] if actual_Class != nil and actual_Class.length > 0 actual_Class = actual_Class.strip if reg_compare(actual_Class, strClass) return true end end return false end |
#find_object_check_Id(element, strId) ⇒ Object
845 846 847 848 849 850 851 852 853 854 855 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 845 def find_object_check_Id(element, strId) actual_Id = element[:id] if actual_Id != nil and actual_Id.length > 0 actual_Id = actual_Id.strip if reg_compare(actual_Id, strId) return true end end return false end |
#find_object_check_maxHeight(element, maxHeight) ⇒ Object
928 929 930 931 932 933 934 935 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 928 def find_object_check_maxHeight(element, maxHeight) height = element[:height] if (height <= maxHeight) return true end return false end |
#find_object_check_maxWidth(element, maxWidth) ⇒ Object
912 913 914 915 916 917 918 919 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 912 def find_object_check_maxWidth(element, maxWidth) width = element[:width] if (width <= maxWidth) return true end return false end |
#find_object_check_minHeight(element, minHeight) ⇒ Object
920 921 922 923 924 925 926 927 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 920 def find_object_check_minHeight(element, minHeight) height = element[:height] if (height <= minHeight) return true end return false end |
#find_object_check_minWidth(element, minWidth) ⇒ Object
904 905 906 907 908 909 910 911 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 904 def find_object_check_minWidth(element, minWidth) width = element[:width] if (width >= minWidth) return true end return false end |
#find_object_check_Name(element, strName) ⇒ Object
867 868 869 870 871 872 873 874 875 876 877 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 867 def find_object_check_Name(element, strName) actual_Name = element[:name] if actual_Name != nil and actual_Name.length > 0 actual_Name = actual_Name.strip if reg_compare(actual_Name, strName) return true end end return false end |
#find_object_check_object(cur_element, ref_object, ref_object_type, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros) ⇒ Object
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 740 def find_object_check_object(cur_element, ref_object, ref_object_type, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros) passCheck = true if cur_element != nil # Check ref_object if (ref_object != nil) if find_object_check_ref_object(ref_object, ref_object_type, cur_element) == false passCheck = false end end # Check ID if strId != nil and strId.length > 0 if strId =~ /^#/ strId = strId[1..-1] end if find_object_check_Id(cur_element, strId) == false passCheck = false end end # Check Class if passCheck and strClass != nil and strClass.length > 0 if strClass =~ /^#/ strClass = strClass[1..-1] end if find_object_check_Class(cur_element, strClass) == false passCheck = false end end # Check Name if passCheck and strName != nil and strName.length > 0 if strName =~ /^#/ strName = strName[1..-1] end if find_object_check_Name(cur_element, strName) == false passCheck = false end end # Check Tag name if passCheck and strTagname != nil and strTagname.length > 0 if find_object_check_Tagname(cur_element, strTagname) == false passCheck = false end end # Check Text if passCheck and strText != nil and strText.length > 0 if (strText =~ /^#/) strText = strText[1..-1] end if find_object_check_Text(cur_element, strText) == false passCheck = false end end # Check minWidth if passCheck and minWidth > 0 if !find_object_check_minWidth(cur_element, minWidth) passCheck = false end end # Check maxWidth if passCheck and maxWidth > 0 if !find_object_check_maxWidth(cur_element, maxWidth) passCheck = false end end # Check minHeight if passCheck and minHeight > 0 if !find_object_check_minHeight(cur_element, minHeight) passCheck = false end end # Check maxHeight if passCheck and maxHeight > 0 if !find_object_check_maxHeight(cur_element, maxHeight) passCheck = false end end # Check another properties if passCheck and ano_pros.length > 0 ano_pros.each{|property, value| if value =~ /^#/ value = value[1..-1] end if !find_object_check_property(cur_element, property, value) passCheck = false break end } end return passCheck end return false end |
#find_object_check_ref_object(ref_object, ref_type, target_element) ⇒ Object
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 937 def find_object_check_ref_object(ref_object, ref_type, target_element) begin ref = ref_object.native target = target_element.native if(ref_type == "up" or ref_type == "down") ref_x1 = ref.location.x - 10 ref_x2 = ref.location.x + ref.size.width + 10 target_x1 = target.location.x target_x2 = target_x1 + target.size.width elsif(ref_type == "left" or ref_type == "right") ref_y1 = ref.location.y - 10 ref_y2 = ref.location.y + ref_object.native.size.height + 10 target_y1 = target.location.y target_y2 = target_y1 + target.size.height elsif(ref_type == "child" or ref_type == "parent") ref_W = ref.location.x + ref.size.width ref_H = ref.location.y + ref.size.height target_W = target.location.x + target.size.width target_H = target.location.y + target.size.height end if(ref_type == "up" and target_x1 > ref_x1 and target_x2 < ref_x2 and # has same column or X Position target.location.y < ref.location.y) # at row or Y position, target is upper return true elsif(ref_type == "down" and target_x1 > ref_x1 and target_x2 < ref_x2 and # has same column or X Position target.location.y > ref.location.y) # at row or Y position, target is at down return true elsif(ref_type == "left" and target.location.x < ref.location.x and # at column or X Position, target is at left target_y1 > ref_y1 and target_y2 < ref_y2) # at row or Y position, target is same as ref object return true elsif(ref_type == "right" and target.location.x > ref.location.x and # at column or X Position, target is at right target_y1 > ref_y1 and target_y2 < ref_y2) # at row or Y position, target is same as ref object return true elsif(ref_type == "child" and (target_W < ref_W) and (target_H < ref_H) and (target.location.x > ref.location.x) and (target.location.y > ref.location.y)) return true elsif(ref_type == "parent" and (target_W > ref_W) and (target_H > ref_H) and (target.location.x < ref.location.x) and (target.location.y < ref.location.y)) return true end rescue StandardError => e puts "❌ Error: #{e}" end return false; end |
#find_object_check_Tagname(element, strTagname) ⇒ Object
879 880 881 882 883 884 885 886 887 888 889 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 879 def find_object_check_Tagname(element, strTagname) actual_Tagname = element.tag_name() if actual_Tagname != nil and actual_Tagname.length > 0 actual_Tagname = actual_Tagname.strip if reg_compare(actual_Tagname, strTagname) return true end end return false end |
#find_object_check_Text(element, strText) ⇒ Object
893 894 895 896 897 898 899 900 901 902 903 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 893 def find_object_check_Text(element, strText) actual_Text = element.text() if actual_Text != nil and actual_Text.length > 0 actual_Text = actual_Text.strip if reg_compare(actual_Text, strText) return true end end return false end |
#find_object_check_Xpath(element, strXpath) ⇒ Object
890 891 892 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 890 def find_object_check_Xpath(element, strXpath) end |
#generate_xpath_selector(strId, strClass, strName, strTagname) ⇒ Object
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 646 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_computed_style(element, style) ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 287 def get_computed_style(element, style) foundElement = get_object_value(element) computedStyle = "" if foundElement != nil computedStyle = page.evaluate_script("window.getComputedStyle(document.querySelector('#{foundElement}')).#{style}") else puts "❌ Error: Not found object: #{element}" exit(1) end puts "\nActual object style value is: #{computedStyle}" computedStyle end |
#get_element_attribute(element, value) ⇒ Object
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 334 def get_element_attribute(element,value) foundElement = find_object(element) if foundElement != nil begin result = foundElement.value() puts "Attribute of #{element}: #{result}" rescue StandardError => e puts "❌ Error: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#get_element_text(element) ⇒ Object
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 318 def get_element_text(element) foundElement = find_object(element) if foundElement != nil begin result = foundElement.text() puts "Text of #{element}: #{result}" rescue StandardError => e puts "❌ Error: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#get_object_and_store_as_string(object, string) ⇒ Object
990 991 992 993 994 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 990 def get_object_and_store_as_string(object,string) text = execute_gettext(object) txt = "'" + text + "'" set_var(string, txt) end |
#get_object_and_store_to_file(object, file_name) ⇒ Object
997 998 999 1000 1001 1002 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 997 def get_object_and_store_to_file(object,file_name) $text = execute_gettext(object) open($test_data_dir+file_name, 'a+') do |f| f << $text + "\n" end end |
#get_object_value(str_obj) ⇒ Object
304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 304 def get_object_value(str_obj) string_object = str_obj.gsub(/"/, "'") hash_object = $OBJECT[string_object] if hash_object == nil raise ">>> OBJECT: #{str_obj} NAME MAYBE NOT FOUND!!!" exit(1) end if hash_object.keys[0].to_s.upcase != "CSS_SELECTOR" raise ">>> OBJECT: #{str_obj} should be formatted as Css Selector." exit(1) end hash_object[hash_object.keys[0]] end |
#get_objects_by_Class(strClass) ⇒ Object
687 688 689 690 691 692 693 694 695 696 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 687 def get_objects_by_Class(strClass) foundElements = nil begin foundElements = page.all("*[@class='#{strClass}']") rescue StandardError => e puts "❌ Error: #{e}" end return foundElements end |
#get_objects_by_css_selector(strCssSelector) ⇒ Object
720 721 722 723 724 725 726 727 728 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 720 def get_objects_by_css_selector(strCssSelector) foundElements = nil begin foundElements = page.all(:css, strCssSelector) rescue StandardError => e puts "❌ Error: #{e}" end foundElements end |
#get_objects_by_Id(strId) ⇒ Object
676 677 678 679 680 681 682 683 684 685 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 676 def get_objects_by_Id(strId) foundElements = nil begin foundElements = page.all("*[@id='#{strId}']") rescue StandardError => e puts "❌ Error: #{e}" end return foundElements end |
#get_objects_by_Name(strName) ⇒ Object
698 699 700 701 702 703 704 705 706 707 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 698 def get_objects_by_Name(strName) foundElements = nil begin foundElements = page.all("*[@name='#{strName}']") rescue StandardError => e puts "❌ Error: #{e}" end return foundElements end |
#get_objects_by_Tagname(strTagname) ⇒ Object
709 710 711 712 713 714 715 716 717 718 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 709 def get_objects_by_Tagname(strTagname) foundElements = nil begin foundElements = page.all("#{strTagname}") rescue StandardError => e puts "❌ Error: #{e}" end return foundElements end |
#get_objects_by_xpath_selector(strXpathSelector) ⇒ Object
730 731 732 733 734 735 736 737 738 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 730 def get_objects_by_xpath_selector(strXpathSelector) foundElements = nil begin foundElements = page.all(:xpath, strXpathSelector) rescue StandardError => e puts "❌ Error: #{e}" end foundElements end |
#maximize_browser ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 78 def maximize_browser begin page.driver.browser.manage.window.maximize rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |
#movemouseandclick(var, element) ⇒ Object
1043 1044 1045 1046 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 1043 def movemouseandclick var, element Selenium::WebDriver::Support::Select.new(page.driver.browser.find_element(:id, "#{var}")).select_by(:text, "#{element}") page.driver.browser.find_element(:id, "#{var}").click end |
#print_variable(variable) ⇒ Object
159 160 161 |
# File 'lib/Ifd_Automation/auto_util.rb', line 159 def print_variable(variable) puts "VALUE OF #{variable}: #{eval_with_dyn_vars(variable)}" end |
#put_log(str) ⇒ Object
300 301 302 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 300 def put_log str p str if $print_log == true end |
#refresh ⇒ Object
161 162 163 164 165 166 167 168 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 161 def refresh begin page.execute_script('window.location.reload()') rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end end |
#reg_compare(sActual, regValue, isSpecialChar = false) ⇒ Object
Assert 2 values
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/Ifd_Automation/assertion_helper.rb', line 18 def reg_compare sActual, regValue, isSpecialChar=false begin if !isSpecialChar sActual = sActual.strip regValue = regValue.strip.gsub("[", "\\[").gsub("]", "\\]").gsub("(", "\\(").gsub(")", "\\)").gsub(">", "\\>") end rescue StandardError => myStandardError raise "\n>>> Error: #{myStandardError}" end # put_log "\nsActual:#{sActual}, regValue:#{regValue}" if ((sActual.nil? and regValue.nil?) or (!sActual.nil? and sActual.empty? and !regValue.nil? and regValue.empty?)) return true end if ((sActual.nil? and !regValue.nil?) or (!sActual.nil? and regValue.nil?)) return false end if (!sActual.nil? and !sActual.empty?) sCookActual = sActual.gsub(/\n|\r/, " ") if (sCookActual == regValue or (isSpecialChar and sCookActual.include? regValue) or (!isSpecialChar and sCookActual =~ /^.*#{regValue}.*$/)) return true end end return false end |
#remove_element_attribute(element, attr) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 228 def remove_element_attribute(element, attr) foundElement = find_object(element) if foundElement != nil begin page.driver.browser.execute_script("arguments[0].removeAttribute('#{attr}');", foundElement.native) sleep(1) rescue StandardError => e puts "❌ Error: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#replace_day(str) ⇒ Object
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/Ifd_Automation/auto_util.rb', line 133 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
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/Ifd_Automation/auto_util.rb', line 122 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
144 145 146 147 148 149 150 |
# File 'lib/Ifd_Automation/auto_util.rb', line 144 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
117 118 119 120 |
# File 'lib/Ifd_Automation/auto_util.rb', line 117 def replace_year str t = Time.now() return str.gsub("{year}", t.year.to_s) end |
#resize_window_screen(x, y) ⇒ Object
268 269 270 271 272 273 274 275 276 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 268 def resize_window_screen(x, y) begin page.driver.browser.manage.window.resize_to(x, y) puts page.driver.browser.manage.window.size rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |
#resolve_params(url) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/Ifd_Automation/auto_util.rb', line 29 def resolve_params url condition = url.match(/params='([^']*)'/)[0] if condition params_name = url.match(/params='([^']*)'/)[1] params_value = $PARAMS["#{params_name.downcase}"].to_s.strip if params_value.present? url = url.gsub(condition, params_value) else raise "ERROR: no data found with given params #{params_name}" end end url end |
#scroll_to_end_page ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 103 def scroll_to_end_page begin page.driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));') rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |
#scroll_to_top_page ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 112 def scroll_to_top_page begin page.driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);') rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |
#set_var(var_name, var_value) ⇒ Object
set value to a variable
7 8 9 10 11 12 13 14 |
# File 'lib/Ifd_Automation/auto_util.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 |
#store_string_as_variable(string, variable) ⇒ Object
152 153 154 155 156 157 |
# File 'lib/Ifd_Automation/auto_util.rb', line 152 def store_string_as_variable(string,variable) # $context_value = bind_with_dyn_vars(string) # set_var(variable, '$context_value') require 'erb' ERB.new(string, 0, "", "#{variable}").result(binding) end |
#switch_to_frame(element) ⇒ Object
278 279 280 281 282 283 284 285 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 278 def switch_to_frame(element) begin page.driver.browser.switch_to.frame element rescue Exception => e puts "❌ Error: #{e}" exit(1) end end |
#switch_to_window_by_title(window_title) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 87 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 } if @window_found == false raise "Window having title \"#{window_title}\" not found" exit(1) end end |
#validate_option_by(option_by) ⇒ Object
475 476 477 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 475 def validate_option_by(option_by) raise "Please select valid option, invalid option - #{option_by}" unless check_valid_option_by? option_by end |
#validate_supported_keys(key) ⇒ Object
483 484 485 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 483 def validate_supported_keys(key) raise "Please select valid keys, invalid key - #{key}" unless check_valid_option_by? key end |
#var_collect(string_var) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/Ifd_Automation/auto_util.rb', line 97 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 |
#verify_alert_text(text) ⇒ Object
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 132 def verify_alert_text(text) begin alert = page.driver.browser.switch_to.alert.text puts "Actual Page alert text : #{alert}, Expected value : #{text}" expect(alert).to eq text rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |
#verify_element_not_has_text(element, value) ⇒ Object
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 367 def verify_element_not_has_text(element,value) foundElement = find_object(element) if foundElement != nil begin actual_value = foundElement.text() put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'" expect(actual_value).not_to eql value rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#verify_element_not_has_value(element, value) ⇒ Object
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 402 def verify_element_not_has_value(element,value) foundElement = find_object(element) if foundElement != nil begin actual_value = foundElement.value() put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'" expect(actual_value).not_to eql value rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#verify_element_text(element, value) ⇒ Object
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 350 def verify_element_text(element,value) foundElement = find_object(element) if foundElement != nil begin actual_value = foundElement.text() put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'" expect(actual_value).to eq value rescue Exception => e puts "❌ ERROR: #{e} " exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#verify_element_value(element, value) ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 385 def verify_element_value(element,value) foundElement = find_object(element) if foundElement != nil begin actual_value = foundElement.value() put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'" expect(actual_value).to eq value rescue Exception => e puts "❌ ERROR: #{e}" exit(1) end else puts "❌ Error: Not found object: #{element}" exit(1) end end |
#verify_title(expected_title) ⇒ Object
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/Ifd_Automation/web_steps_helper.rb', line 121 def verify_title(expected_title) begin page_title = page.title puts "Actual Page Title : #{page_title}, Expected Page Title : #{expected_title}" expect(page_title).to eq expected_title rescue StandardError => e puts "❌ Error: #{e}" exit(1) end end |