admin_module 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +2 -0
  4. data/README.md +7 -0
  5. data/admin_module.gemspec +3 -1
  6. data/{bin → exe}/admin_module +0 -0
  7. data/lib/admin_module.rb +9 -0
  8. data/lib/admin_module/command/config.rb +20 -0
  9. data/lib/admin_module/command/gdl.rb +15 -0
  10. data/lib/admin_module/guideline.rb +8 -0
  11. data/lib/admin_module/page_factory.rb +43 -2
  12. data/lib/admin_module/pages.rb +38 -81
  13. data/lib/admin_module/pages/guideline_page.rb +54 -1
  14. data/lib/admin_module/pages/guideline_page_400.rb +87 -0
  15. data/lib/admin_module/pages/guideline_version_page.rb +9 -5
  16. data/lib/admin_module/pages/guidelines_page.rb +40 -34
  17. data/lib/admin_module/pages/guidelines_page_400.rb +65 -0
  18. data/lib/admin_module/pages/guidelines_version_all_page.rb +79 -72
  19. data/lib/admin_module/pages/guidelines_version_all_page_400.rb +122 -0
  20. data/lib/admin_module/pages/login_page.rb +2 -2
  21. data/lib/admin_module/pages/login_page_400.rb +73 -0
  22. data/lib/admin_module/version.rb +1 -1
  23. data/spec/data/config/no_ams_version.admin_module +11 -0
  24. data/spec/data/html/guideline-400.html +2713 -0
  25. data/spec/data/html/guideline-400_files/BindChildren.js +852 -0
  26. data/spec/data/html/guideline-400_files/CVlogo.jpg +0 -0
  27. data/spec/data/html/guideline-400_files/Guideline.js +301 -0
  28. data/spec/data/html/guideline-400_files/OptimalOutcome.png +0 -0
  29. data/spec/data/html/guideline-400_files/WebResource(1).axd +561 -0
  30. data/spec/data/html/guideline-400_files/WebResource.axd +548 -0
  31. data/spec/data/html/guideline-400_files/styles.css +444 -0
  32. data/spec/data/html/guideline-400_files/styles2.css +115 -0
  33. data/spec/data/html/guideline-400_files/tab.css +50 -0
  34. data/spec/data/html/guideline-400_files/tabpane.js +297 -0
  35. data/spec/data/html/guideline.html +1809 -0
  36. data/spec/data/html/guideline_files/BindChildren.js +799 -0
  37. data/spec/data/html/guideline_files/Guideline.js +300 -0
  38. data/spec/data/html/guideline_files/LeftMenu.html +0 -0
  39. data/spec/data/html/guideline_files/MainFrame.html +18 -0
  40. data/spec/data/html/guideline_files/ScriptResource.axd +3725 -0
  41. data/spec/data/html/guideline_files/Stylesheet.css +1545 -0
  42. data/spec/data/html/guideline_files/WebResource(1).axd +0 -0
  43. data/spec/data/html/guideline_files/WebResource(2).axd +566 -0
  44. data/spec/data/html/guideline_files/WebResource(3).axd +219 -0
  45. data/spec/data/html/guideline_files/WebResource.axd +696 -0
  46. data/spec/data/html/guideline_files/framebar.html +0 -0
  47. data/spec/data/html/guideline_files/guideline.html +0 -0
  48. data/spec/data/html/guideline_files/home.png +0 -0
  49. data/spec/data/html/guideline_files/jquery-ui.css +578 -0
  50. data/spec/data/html/guideline_files/jquery.js +7 -0
  51. data/spec/data/html/guideline_files/slidebar.gif +29 -0
  52. data/spec/data/html/guideline_files/tab.css +49 -0
  53. data/spec/data/html/guideline_files/tabpane.js +297 -0
  54. data/spec/data/html/guidelines-400.html +368 -0
  55. data/spec/data/html/guidelines-400_files/CVlogo.jpg +0 -0
  56. data/spec/data/html/guidelines-400_files/EditListSearchHelper.js +141 -0
  57. data/spec/data/html/guidelines-400_files/OptimalOutcome.png +0 -0
  58. data/spec/data/html/guidelines-400_files/WebResource(1).axd +561 -0
  59. data/spec/data/html/guidelines-400_files/WebResource.axd +548 -0
  60. data/spec/data/html/guidelines-400_files/menu.css +29 -0
  61. data/spec/data/html/guidelines-400_files/menu.js +48 -0
  62. data/spec/data/html/guidelines-400_files/shadow.gif +0 -0
  63. data/spec/data/html/guidelines-400_files/styles.css +444 -0
  64. data/spec/data/html/guidelines-400_files/styles2.css +115 -0
  65. data/spec/data/html/guidelines.html +217 -0
  66. data/spec/data/html/guidelines_files/EditListSearchHelper.js +123 -0
  67. data/spec/data/html/guidelines_files/ScriptResource.axd +3725 -0
  68. data/spec/data/html/guidelines_files/Stylesheet.css +1545 -0
  69. data/spec/data/html/guidelines_files/jquery-ui.css +578 -0
  70. data/spec/data/html/login.aspx.html +293 -0
  71. data/spec/data/html/login.aspx_files/ScriptResource.axd +3332 -0
  72. data/spec/data/html/login.aspx_files/Stylesheet.css +1545 -0
  73. data/spec/data/html/login.aspx_files/jquery-ui.css +578 -0
  74. data/spec/data/html/login.aspx_files/jquery.js +7 -0
  75. data/spec/data/html/login400.aspx.html +191 -0
  76. data/spec/data/html/login400.aspx_files/WebResource(1).axd +561 -0
  77. data/spec/data/html/login400.aspx_files/WebResource.axd +548 -0
  78. data/spec/data/html/login400.aspx_files/styles.css +444 -0
  79. data/spec/data/html/version_all_guidelines-400.html +702 -0
  80. data/spec/data/html/version_all_guidelines-400_files/CVlogo.jpg +0 -0
  81. data/spec/data/html/version_all_guidelines-400_files/Calendar.js +521 -0
  82. data/spec/data/html/version_all_guidelines-400_files/OptimalOutcome.png +0 -0
  83. data/spec/data/html/version_all_guidelines-400_files/TwoSelects.js +300 -0
  84. data/spec/data/html/version_all_guidelines-400_files/menu.css +29 -0
  85. data/spec/data/html/version_all_guidelines-400_files/menu.js +48 -0
  86. data/spec/data/html/version_all_guidelines-400_files/shadow.gif +0 -0
  87. data/spec/data/html/version_all_guidelines-400_files/styles(1).css +134 -0
  88. data/spec/data/html/version_all_guidelines-400_files/styles.css +444 -0
  89. data/spec/data/html/version_all_guidelines-400_files/styles2.css +115 -0
  90. data/spec/data/html/version_all_guidelines.html +560 -0
  91. data/spec/data/html/version_all_guidelines_files/Calendar.js +521 -0
  92. data/spec/data/html/version_all_guidelines_files/ScriptResource.axd +3725 -0
  93. data/spec/data/html/version_all_guidelines_files/Stylesheet.css +1545 -0
  94. data/spec/data/html/version_all_guidelines_files/TwoSelects.js +304 -0
  95. data/spec/data/html/version_all_guidelines_files/jquery-ui.css +578 -0
  96. data/spec/lib/admin_module/command/config_spec.rb +27 -0
  97. data/spec/lib/admin_module/command/gdl_spec.rb +31 -0
  98. data/spec/lib/admin_module/configuration_spec.rb +47 -0
  99. data/spec/lib/admin_module/guideline_spec.rb +26 -0
  100. data/spec/lib/admin_module/page_factory_spec.rb +72 -0
  101. data/spec/lib/admin_module/pages/guideline_page_400_spec.rb +51 -0
  102. data/spec/lib/admin_module/pages/guideline_page_spec.rb +50 -0
  103. data/spec/lib/admin_module/pages/guidelines_page_400_spec.rb +92 -0
  104. data/spec/lib/admin_module/pages/guidelines_page_spec.rb +91 -0
  105. data/spec/lib/admin_module/pages/guidelines_version_all_page_400_spec.rb +102 -0
  106. data/spec/lib/admin_module/pages/guidelines_version_all_page_spec.rb +105 -0
  107. data/spec/lib/admin_module/pages/login_page_400_spec.rb +42 -0
  108. data/spec/lib/admin_module/pages/login_page_spec.rb +33 -0
  109. data/spec/support/html_spec.rb +26 -0
  110. data/spec/support/mocks.rb +23 -0
  111. metadata +191 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 156ed751adc5e34fd1010ef58764dd5d4400f158
4
- data.tar.gz: 1a4085172ca575a5ff76e734a6f6105a7ef7159b
3
+ metadata.gz: 151be951731550875de370d3b775eab9cc9656d9
4
+ data.tar.gz: c8ccdecaf21e25bbe7a6ad5ff6a36fcf3ede651c
5
5
  SHA512:
6
- metadata.gz: 1feb0fa4192586136c7bfa6d03d0741c67bb081e76190c8a8b3720241018137db0172ef411b8ccfc197b0dafbb7810f2f9f304907efbcbd99398f1ebf96e8a62
7
- data.tar.gz: f4a3fcab406fe0b74f835d7856a20ce31f4ca64cb17051e9bbc8408ca53669eb19b854cfd667a9b144fbd7d8adfd8d07888bb48545233fe58ad29cabe6f5ac38
6
+ metadata.gz: ceb415bff96ba84482428aa52d51448c99965c1f76393fc3f1f154408d684d74b39254a4a74cd9c8fb7aa970a6c40b856c8f615f1ee50c648c067af57e382362
7
+ data.tar.gz: 0f896e696fd4528c1dc2fa72ed2c8d6ebd9afd2b48d92896cc71ebf9d1577e4ae9619d8211df04e20ef74901f7c1fcf6dbc9e3cd2a6ce627a8634a61089643ed
data/.gitignore CHANGED
@@ -15,5 +15,6 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- test/chrome-data
18
+ /test/
19
19
  .admin_module
20
+ bin/
data/Gemfile CHANGED
@@ -9,6 +9,8 @@ group :development do
9
9
  gem 'pry-stack_explorer'
10
10
  end
11
11
 
12
+ #gem 'browser_loader', :git => 'git://github.com/jmcaffee/browser_loader', :branch => 'dev'
13
+
12
14
  # Specify your gem's dependencies in admin_module.gemspec
13
15
  gemspec
14
16
 
data/README.md CHANGED
@@ -48,6 +48,7 @@ is listed here.
48
48
  admin_module config help [COMMAND] # Describe subcommands or one specific subcommand
49
49
  admin_module config defcomment '<comment>' # show or set the default comment
50
50
  admin_module config defenv <envname> # show or set the default environment
51
+ admin_module config amsversion <version> # show or set the AMS admin module version
51
52
  admin_module config init <filedir> # create a configuration file
52
53
  admin_module config timeout <seconds> # show or set the browser timeout period
53
54
  admin_module config show [CATEGORY] # display configuration values for [CATEGORY]
@@ -272,6 +273,12 @@ interface to the actual Guideline page object.
272
273
  page, select a guideline, then go to the _GuidelineDetails_ page before it can
273
274
  manipulate a guideline, say, to change its name.
274
275
 
276
+ ## Testing
277
+
278
+ The specs are tested with the latest version of Chromium (44.0.2403.89) and
279
+ [chromedriver](http://chromedriver.storage.googleapis.com/index.html?path=2.19/)] (2.19)
280
+ at this time.
281
+
275
282
  ## LICENSE
276
283
 
277
284
  AdminModule is licensed under the MIT license.
@@ -13,8 +13,9 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/jmcaffee/admin_module"
14
14
  spec.license = "MIT"
15
15
 
16
+ spec.bindir = 'exe'
16
17
  spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
20
  spec.require_paths = ["lib"]
20
21
 
@@ -31,4 +32,5 @@ Gem::Specification.new do |spec|
31
32
  spec.add_runtime_dependency "page-object"
32
33
  spec.add_runtime_dependency "thor"
33
34
  spec.add_runtime_dependency "ktutils"
35
+ spec.add_runtime_dependency "browser_loader"
34
36
  end
File without changes
@@ -1,3 +1,4 @@
1
+ require "browser_loader"
1
2
  require "admin_module/version"
2
3
  require 'admin_module/config_helper'
3
4
  require "admin_module/cli"
@@ -123,10 +124,14 @@ module AdminModule
123
124
  attr_accessor :xmlmaps
124
125
  attr_accessor :aliases
125
126
  attr_accessor :page_urls
127
+ attr_accessor :ams_version
126
128
 
127
129
  # Browser timeout in seconds. Default: 360 (6 mins).
128
130
  attr_accessor :browser_timeout
129
131
 
132
+ # Browser download directory. Default: none
133
+ attr_accessor :download_dir
134
+
130
135
 
131
136
  def initialize
132
137
  reset
@@ -158,7 +163,11 @@ module AdminModule
158
163
  'ParameterPage' => "/admin/decision/parameter.aspx",
159
164
  }
160
165
 
166
+ @ams_version = "4.4.0"
167
+
161
168
  @browser_timeout = 360
169
+
170
+ @download_dir = ""
162
171
  end
163
172
 
164
173
  ##
@@ -290,6 +290,26 @@ module AdminModule
290
290
  end
291
291
  end
292
292
 
293
+
294
+ desc "amsversion <version>", "show or set the admin module version"
295
+ long_desc <<-LD
296
+ Show or set the AMS Admin Module version being used.
297
+
298
+ The default version will be 4.4.0 when no version is configured.
299
+ LD
300
+ def amsversion(version=nil)
301
+ if version.nil?
302
+ with_loaded_config do
303
+ say "ams version: #{AdminModule.configuration.ams_version}"
304
+ end
305
+ return
306
+ end
307
+
308
+ with_loaded_config(true) do
309
+ AdminModule.configuration.ams_version = version
310
+ end
311
+ end
312
+
293
313
  private
294
314
 
295
315
  def with_loaded_config save = false
@@ -66,6 +66,21 @@ module AdminModule
66
66
 
67
67
  client.logout
68
68
  end
69
+
70
+ desc "download <guideline> <to_path>",
71
+ "Download guideline XML to destination path (includes filename)"
72
+ long_desc <<-LD
73
+ Download a guideline's XML and save it to a specified path and filename.
74
+
75
+ With -e <env>, sets the environment to work with.
76
+ LD
77
+ def download(guideline, to_path)
78
+ gdl = client.guideline
79
+
80
+ gdl.download(guideline, to_path)
81
+
82
+ client.logout
83
+ end
69
84
  end # Gdl
70
85
  end
71
86
  end # AdminModule
@@ -35,6 +35,14 @@ module AdminModule
35
35
  .upload(xmlfile.expand_path, comments_or_default(comments))
36
36
  end
37
37
 
38
+ def download gdlname, xmlfile
39
+ xmlfile = Pathname(xmlfile)
40
+
41
+ page = guidelines_page
42
+ .open_guideline(gdlname)
43
+ .download(xmlfile.expand_path)
44
+ end
45
+
38
46
  def version gdls, comments = nil
39
47
  gdls = Array(gdls)
40
48
  page = guidelines_page
@@ -12,12 +12,53 @@ module AdminModule
12
12
  class PageFactory
13
13
  include AdminModule::Pages
14
14
 
15
+ def default_ams_version
16
+ "4.4.0"
17
+ end
18
+
19
+ def ams_version
20
+ AdminModule.configuration.ams_version
21
+ end
22
+
23
+ def running_older_version?
24
+ Gem::Version.new(ams_version) < Gem::Version.new(default_ams_version)
25
+ end
26
+
15
27
  def login_page(goto_page = true)
16
- return Pages::LoginPage.new(browser, goto_page)
28
+ case running_older_version?
29
+ when true
30
+ return Pages::LoginPage400.new(browser, goto_page)
31
+ else
32
+ return Pages::LoginPage.new(browser, goto_page)
33
+ end
17
34
  end
18
35
 
36
+ def guidelines_version_all_page(goto_page = true)
37
+ case running_older_version?
38
+ when true
39
+ return Pages::GuidelinesVersionAllPage400.new(browser, goto_page)
40
+ else
41
+ return Pages::GuidelinesVersionAllPage.new(browser, goto_page)
42
+ end
43
+ end
44
+
45
+
19
46
  def guidelines_page(goto_page = true)
20
- return Pages::GuidelinesPage.new(browser, goto_page)
47
+ case running_older_version?
48
+ when true
49
+ return Pages::GuidelinesPage400.new(browser, goto_page)
50
+ else
51
+ return Pages::GuidelinesPage.new(browser, goto_page)
52
+ end
53
+ end
54
+
55
+ def guideline_page(goto_page = false)
56
+ case running_older_version?
57
+ when true
58
+ return Pages::GuidelinePage400.new(browser, goto_page)
59
+ else
60
+ return Pages::GuidelinePage.new(browser, goto_page)
61
+ end
21
62
  end
22
63
 
23
64
  def rulesets_page(goto_page = true)
@@ -10,9 +10,13 @@ require 'watir-webdriver'
10
10
  require 'ktutils/os'
11
11
  require 'admin_module/pages/select_list_syncable'
12
12
  require 'admin_module/pages/login_page'
13
+ require 'admin_module/pages/login_page_400'
13
14
  require 'admin_module/pages/guidelines_page'
15
+ require 'admin_module/pages/guidelines_page_400'
14
16
  require 'admin_module/pages/guidelines_version_all_page'
17
+ require 'admin_module/pages/guidelines_version_all_page_400'
15
18
  require 'admin_module/pages/guideline_page'
19
+ require 'admin_module/pages/guideline_page_400'
16
20
  require 'admin_module/pages/guideline_version_page'
17
21
  require 'admin_module/pages/lock_definitions_page'
18
22
  require 'admin_module/pages/lock_definition_page'
@@ -34,96 +38,49 @@ require 'admin_module/pages/snapshot_detail_page'
34
38
  require 'admin_module/pages/workflow_task_page'
35
39
  require 'admin_module/pages/workflow_tasks_page'
36
40
  require 'admin_module/pages/ppms_page'
41
+ require 'browser_loader'
37
42
 
38
43
  module AdminModule::Pages
39
44
 
40
- ##
41
- # Return a configured browser object. If a browser has already been created,
42
- # this returns the existing browser.
43
- #
44
- # An +at_exit+ proc is created to close the browser when the program exits.
45
-
46
- def browser
47
- if @browser.nil?
48
- @browser = configure_browser
49
-
50
- at_exit do
51
- @browser.close unless @browser.nil?
45
+ class BrowserInst
46
+ @@browser = nil
47
+
48
+ ##
49
+ # Return a configured browser object. If a browser has already been created,
50
+ # this returns the existing browser.
51
+ #
52
+ # An +at_exit+ proc is created to close the browser when the program exits.
53
+
54
+ def self.browser
55
+ if ! open_browser?
56
+ BrowserLoader::Factory.browser_timeout = AdminModule.configuration.browser_timeout
57
+ BrowserLoader::Factory.download_dir = AdminModule.configuration.download_dir unless AdminModule.configuration.download_dir.empty?
58
+ @@browser = BrowserLoader::Factory.build
59
+
60
+ at_exit do
61
+ unless ! open_browser?
62
+ # Make sure every webdriver window is closed.
63
+ @@browser.windows.each { |w| w.close rescue nil }
64
+ @@browser.close rescue nil
65
+ end
66
+ end
52
67
  end
53
- end
54
-
55
- @browser
56
- end
57
-
58
- private
59
68
 
60
- def chromium_exe
61
- if Ktutils::OS.windows?
62
- # Downloaded from http://chromium.woolyss.com/
63
- # Package: Chromium Package (32-bit)
64
- # Version: 37.0.2011.0 (272392)
65
- chromium_exe = ENV["chrome_browser_path"]
66
- unless (! chromium_exe.nil? && ! chromium_exe.empty? && File.exist?(chromium_exe))
67
- raise "chrome_browser_path environment variable not set"
68
- end
69
- #chromium_exe = File.absolute_path(File.join(__FILE__, '../../../bin/chrome-win32/chrome.exe'))
70
- chromium_exe
71
- else
72
- chromium_exe = `which chromium-browser`.chomp
69
+ @@browser
73
70
  end
74
- end
75
-
76
- def configure_browser
77
- # We must clear out any environmental proxy or Selenium fails
78
- # to connect to the local application.
79
- ENV['http_proxy'] = nil
80
71
 
81
- # Specify chrome browser capabilities.
82
- caps = Selenium::WebDriver::Remote::Capabilities.chrome
83
- caps['chromeOptions'] = {'binary' => chromium_exe }
84
- #caps['chromeOptions'] = {'binary' => '/opt/bin/test/chrome-27.0.1453.94.exe' }
85
- # See http://peter.sh/experiments/chromium-command-line-switches/ for a list of available switches.
86
- # See https://sites.google.com/a/chromium.org/chromedriver/capabilities for details on setting ChromeDriver caps.
87
-
88
- # NOTE: The only way I've found to stop the EULA from being displayed is to
89
- # use the user-data-dir switch and point to a dir where chrome can put the
90
- # data indicating it (EULA) has already been accepted.
91
-
92
- # Store chrome profile at test/chrome-data.
93
- # user_data_dir must be expanded to a full (absolute) path. A relative path
94
- # results in chromedriver failing to start.
95
- user_data_dir = File.expand_path('test/chrome-data')
96
- #puts "*** user_data_dir location: #{user_data_dir}"
97
-
98
- # Create the data dir if it doesn't exist (or chromedriver fails to start).
99
- unless File.exists?(user_data_dir) and File.directory?(user_data_dir)
100
- FileUtils.makedirs user_data_dir
72
+ def self.open_browser?
73
+ return (! @@browser.nil? && @@browser.exist? )
101
74
  end
75
+ end
102
76
 
103
- # ignore-certificate-errors: Ignores certificate-related errors.
104
- # disable-popup-blocking: Disable pop-up blocking.
105
- # disable-translate: Allows disabling of translate from the command line to assist with automated browser testing
106
- # no-first-run: Skip First Run tasks, whether or not it's actually the First Run.
107
- # log-level: Sets the minimum log level. Valid values are from 0 to 3: INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3.
108
- switches = %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate --no-first-run --log-level=3]
109
- switches << "--user-data-dir=#{user_data_dir}"
110
-
111
- proxy_port = ENV['BROWSER_PROXY_PORT']
112
- unless proxy_port.nil? || proxy_port.empty?
113
- proxy_connection_string = "socks://localhost:#{proxy_port}"
114
- switches << "--proxy-server=#{proxy_connection_string}"
115
- end
116
-
117
- # Create a client so we can adjust the timeout period.
118
- client = Selenium::WebDriver::Remote::Http::Default.new
119
-
120
- # Set the browser timeout. Default is 60 seconds.
121
- client.timeout = AdminModule.configuration.browser_timeout
77
+ ##
78
+ # Return a configured browser object. If a browser has already been created,
79
+ # this returns the existing browser.
80
+ #
81
+ # An +at_exit+ proc is created to close the browser when the program exits.
122
82
 
123
- browser = Watir::Browser.new :chrome,
124
- :switches => switches,
125
- :http_client => client,
126
- :service_log_path => user_data_dir + '/chromedriver.out',
127
- :desired_capabilities => caps
83
+ def browser
84
+ BrowserInst.browser
128
85
  end
129
86
  end
@@ -28,7 +28,60 @@ module AdminModule::Pages
28
28
  self.add_version_button
29
29
 
30
30
  # Return the next page object.
31
- GuidelineVersionPage.new(@browser, false)
31
+ AdminModule::ConfigHelper.page_factory.guideline_version_page(false)
32
+ #GuidelineVersionPage.new(@browser, false)
33
+ end
34
+
35
+ def download(dest_file_path)
36
+ versions
37
+
38
+ # Get the first download link.
39
+ dl_link = link_elements.find do |e|
40
+ e.text == "Download"
41
+ end
42
+
43
+ gdl_id = id_from_href(dl_link.href)
44
+ gdl_version = version_from_href(dl_link.href)
45
+
46
+ # Click the download
47
+ dl_link.click
48
+
49
+ default_filename = "gdl#{gdl_id}.#{gdl_version}.xml"
50
+ downloaded_file = Pathname(AdminModule.configuration.download_dir) + default_filename
51
+
52
+ i = 0
53
+ while !downloaded_file.exist?
54
+ i += 1
55
+ # Wait for download to complete
56
+ sleep 5
57
+
58
+ break if i > 30
59
+ end
60
+
61
+ FileUtils.mv downloaded_file, dest_file_path
62
+ end
63
+
64
+ private
65
+
66
+ def id_from_href href
67
+ str = href.split("?")[1]
68
+ str = str.split("&")[0]
69
+ str = str.split("=")[1]
70
+ end
71
+
72
+ def version_from_href href
73
+ str = href.split("?")[1]
74
+ str = str.split("&")[1]
75
+ str = str.split("=")[1]
76
+ end
77
+
78
+ def latest_version
79
+ doc = Nokogiri::HTML(@browser.html)
80
+ # The specific version notes TD element:
81
+ #version_notes_row_1 = doc.css("#dgrVersions > tbody > tr:nth-child(2) > td:nth-child(13)")
82
+
83
+ # The entire 1st version row (TR) element:
84
+ version_row = doc.css("#dgrVersions > tbody > tr:nth-child(2)")
32
85
  end
33
86
  end
34
87
  end # module Pages
@@ -0,0 +1,87 @@
1
+ ##############################################################################
2
+ # File:: guideline_page_400.rb
3
+ # Purpose:: Guideline page for AdminModule
4
+ #
5
+ # Author:: Jeff McAffee 2015-10-08
6
+ #
7
+ ##############################################################################
8
+ require 'page-object'
9
+
10
+ module AdminModule::Pages
11
+ class GuidelinePage400
12
+ include PageObject
13
+
14
+ #page_url(:get_dynamic_url)
15
+
16
+ def get_dynamic_url
17
+ AdminModule.configuration.base_url + "/admin/decision/guideline.aspx"
18
+ end
19
+
20
+ link(:versions,
21
+ text: 'Versions')
22
+
23
+ button(:add_version_button,
24
+ id: 'cmdAddVersion')
25
+
26
+ def add_version
27
+ self.versions
28
+ self.add_version_button
29
+
30
+ # Return the next page object.
31
+ AdminModule::ConfigHelper.page_factory.guideline_version_page(false)
32
+ end
33
+
34
+ def download(dest_file_path)
35
+ versions
36
+
37
+ # Get the first download link.
38
+ dl_link = link_elements.find do |e|
39
+ e.text == "Download"
40
+ end
41
+
42
+ gdl_id = id_from_href(dl_link.href)
43
+ gdl_version = version_from_href(dl_link.href)
44
+
45
+ # Click the download
46
+ dl_link.click
47
+
48
+ default_filename = "gdl#{gdl_id}.#{gdl_version}.xml"
49
+ downloaded_file = Pathname(AdminModule.configuration.download_dir) + default_filename
50
+
51
+ i = 0
52
+ while !downloaded_file.exist?
53
+ i += 1
54
+ # Wait for download to complete
55
+ sleep 5
56
+
57
+ break if i > 30
58
+ end
59
+
60
+ FileUtils.mv downloaded_file, dest_file_path
61
+ end
62
+
63
+ private
64
+
65
+ def id_from_href href
66
+ str = href.split("?")[1]
67
+ str = str.split("&")[0]
68
+ str = str.split("=")[1]
69
+ end
70
+
71
+ def version_from_href href
72
+ str = href.split("?")[1]
73
+ str = str.split("&")[1]
74
+ str = str.split("=")[1]
75
+ end
76
+
77
+ def latest_version
78
+ doc = Nokogiri::HTML(@browser.html)
79
+ # The specific version notes TD element:
80
+ #version_notes_row_1 = doc.css("#dgrVersions > tbody > tr:nth-child(2) > td:nth-child(13)")
81
+
82
+ # The entire 1st version row (TR) element:
83
+ version_row = doc.css("#dgrVersions > tbody > tr:nth-child(2)")
84
+ end
85
+ end
86
+ end # module Pages
87
+