/driver/web_ipv6/700.060.20.110-cfg_dns_info_web.rb

https://github.com/DarrylBrown/main2 · Ruby · 143 lines · 74 code · 17 blank · 52 comment · 13 complexity · 12e526f4941bae47779a3e1a3f4c5fbf MD5 · raw file

  1. =begin rdoc
  2. *Revisions*
  3. | Change | Name | Date |
  4. *Test_Script_Name*
  5. cfg_dns_info3
  6. *Test_Case_Number*
  7. 700.60.20.110
  8. *Description*
  9. Validate the Network Settings Configuration
  10. - Positive
  11. - Negative
  12. *Variable_Definitions*
  13. s = test start time
  14. f = test finish time
  15. e = test elapsed time
  16. roe = row number in controller spreadsheet
  17. excel = nested array that contains an instance of excel and driver parameters
  18. ss = spreadsheet
  19. wb = workbook
  20. ws = worksheet
  21. dvr_ss = driver spreadsheet
  22. rows = number of rows in spreadsheet to execute
  23. site = url/ip address of card being tested
  24. name = user name for login
  25. pswd = password for login
  26. =end
  27. #Launch the Configure Network Settings ruby script
  28. #Add library file to the path
  29. $:.unshift File.dirname(__FILE__).chomp('driver/web_ipv6')<<'lib' # add library to path
  30. s = Time.now
  31. require 'generic'
  32. require 'watir/process'
  33. begin
  34. puts" \n Executing: #{(__FILE__)}\n\n" # print current filename
  35. g = Generic.new
  36. roe = ARGV[1].to_i
  37. #Open up a new excel instance and save it with the timestamp.
  38. #Open the IE browser
  39. #Collect the support page information and save it in the time stamped spreadsheet.
  40. excel = g.setup(__FILE__)
  41. wb,ws = excel[0][1,2]
  42. rows = excel[1][1]
  43. $ie.speed = :zippy
  44. #Navigate to the 'Configure' tab
  45. g.config.click
  46. $ie.maximize
  47. #Click the Configure DNS Settings link on the left side of window
  48. #Login if not called from controller
  49. g.logn_chk(g.dns,excel[1])
  50. row = 1
  51. while(row <= rows)
  52. puts "Test step #{row}"
  53. row +=1 # add 1 to row as execution starts at drvr_ss row 2
  54. sleep 5
  55. g.edit.click
  56. # Write DNS Server Mode Seletion
  57. dnsmode = ((ws.Range("k#{row}")['Value']).to_i).to_s
  58. puts "#{dnsmode}"
  59. g.dns_mode(dnsmode).set
  60. # Write DNS Pri Server and Sec Address Seletion
  61. if (g.dns_mode(1).checked? == true)
  62. g.dns_addr1.set(ws.Range("l#{row}")['Value'].to_s)
  63. g.dns_addr2.set(ws.Range("m#{row}")['Value'].to_s)
  64. end
  65. # Write Select Resovle Interval time
  66. interval = ((ws.Range("n#{row}")['Value']).to_i).to_s
  67. puts "#{interval}"
  68. g.dns_int.select_value(interval)
  69. #Write DNS Name suffix
  70. g.dns_suf.set(ws.Range("o#{row}")['Value'].to_s)
  71. #Is there a popup expected?
  72. pop = ws.Range("af#{row}")['Value'].to_s
  73. puts " pop_up value = #{pop}" unless pop == 'no'
  74. #sleep 1
  75. #If popup, handle with reset OK or reset Cancel to continue
  76. if (pop == "res")
  77. popup_txt = g.invChar(pop)
  78. puts "Pop-Up text is #{popup_txt}"
  79. ws.Range("bk#{row}")['Value'] = popup_txt
  80. end
  81. if (pop == "can")
  82. ws.Range("bk#{row}")['Value'] = g.res_can(pop)
  83. end
  84. #If reset Cancel, do not save
  85. if (pop == "no")
  86. g.save.click_no_wait
  87. g.jsClick('OK')
  88. end
  89. #read DNS Settings field values
  90. sleep 1
  91. g.edit.click
  92. ws.Range("bf#{row}")['Value'] = g.dns_int.value
  93. ws.Range("bg#{row}")['Value'] = g.dns_suf.value
  94. if (g.dns_mode(1).checked? == true)
  95. ws.Range("bc#{row}")['Value'] = "1"
  96. ws.Range("bd#{row}")['Value'] = g.dns_addr1.value
  97. ws.Range("be#{row}")['Value'] = g.dns_addr2.value
  98. elsif (g.dns_mode(0).checked? == true)
  99. ws.Range("bc#{row}")['Value'] = "0"
  100. else
  101. ws.Range("bc#{row}")['Value'] = "2"
  102. end
  103. g.save.click_no_wait
  104. g.jsClick('OK')
  105. wb.Save
  106. end
  107. f = Time.now #finish time
  108. #Capture error if any in the script
  109. rescue Exception => e
  110. f = Time.now #finish time
  111. puts" \n\n **********\n\n #{$@ } \n\n #{e} \n\n ***"
  112. error_present=$@.to_s
  113. ensure #this section is executed even if script goes in error
  114. # If roe > 0, script is called from controller
  115. # If roe = 0, script is being ran independently
  116. #Close and save the spreadsheet and thes web browser.
  117. g.tear_down_d(excel[0],s,f,roe,error_present)
  118. if roe == 0
  119. $ie.close
  120. end
  121. end