Class: HTMLPageObject
- Inherits:
-
Object
- Object
- HTMLPageObject
- Includes:
- PageHelper, Utilities, Workflows
- Defined in:
- lib/sakai-cle-test-api/data_objects/resource.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#folder ⇒ Object
Returns the value of attribute folder.
-
#html ⇒ Object
(also: #content)
Returns the value of attribute html.
-
#name ⇒ Object
(also: #title)
Returns the value of attribute name.
-
#site ⇒ Object
Returns the value of attribute site.
-
#url ⇒ Object
(also: #href)
Returns the value of attribute url.
Instance Method Summary collapse
- #create ⇒ Object
- #edit_content(html_source) ⇒ Object
-
#initialize(browser, opts = {}) ⇒ HTMLPageObject
constructor
A new instance of HTMLPageObject.
Methods included from Workflows
menu_link, #open_my_site_by_name
Methods included from Utilities
#current_hour, #current_month, #current_year, #get_filename, #in_15_minutes, #last_hour, #last_month, #last_year, #make, #make_date, #next_hour, #next_month, #next_year, #on_page, #random_alphanums, #random_alphanums_plus, #random_email, #random_high_ascii, #random_letters, #random_multiline, #random_nicelink, #random_string, #random_xss_string, #tomorrow, #yesterday
Methods included from PageHelper
#make, #on, #visit, #wait_until
Constructor Details
#initialize(browser, opts = {}) ⇒ HTMLPageObject
Returns a new instance of HTMLPageObject.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 105 def initialize(browser, opts={}) @browser = browser defaults = { :name=>random_alphanums, :description=>random_multiline(100, 15, :alpha), :html=>"<body>Body</body>" } = defaults.merge(opts) @name = [:name] @description = [:description] @site = [:site] @folder = [:folder] @html = [:html] @site = [:site] raise "You must specify a Site for your HTML Page" if @site==nil end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
103 104 105 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 103 def description @description end |
#folder ⇒ Object
Returns the value of attribute folder.
103 104 105 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 103 def folder @folder end |
#html ⇒ Object Also known as: content
Returns the value of attribute html.
103 104 105 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 103 def html @html end |
#name ⇒ Object Also known as: title
Returns the value of attribute name.
103 104 105 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 103 def name @name end |
#site ⇒ Object
Returns the value of attribute site.
103 104 105 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 103 def site @site end |
#url ⇒ Object Also known as: href
Returns the value of attribute url.
103 104 105 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 103 def url @url end |
Instance Method Details
#create ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 128 def create open_my_site_by_name @site unless @browser.title=~/#{@site}/ resources unless @browser.title=~/Resources$/ on_page Resources do |page| page.create_html_page_in @folder end on_page EditHTMLPageContent do |page| page.enter_source_text page.editor, @html page.continue end on_page EditHTMLPageProperties do |page| page.name.set @name page.description.set @description # Put more here as needed later page.finish end on_page Resources do |page| @url = page.href(@name) end end |
#edit_content(html_source) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/sakai-cle-test-api/data_objects/resource.rb', line 149 def edit_content(html_source) open_my_site_by_name @site unless @browser.title=~/#{@site}/ resources unless @browser.title=~/Resources$/ on Resources do |fileslist| fileslist.open_folder @folder unless fileslist.item(@name).present? || @folder==nil fileslist.edit_content @name end on EditHTMLPageContent do |edit| edit.enter_source_text edit.editor, html_source edit.continue end @html=html_source end |