Class: HTMLPageObject

Inherits:
Object
  • Object
show all
Includes:
PageHelper, Utilities, Workflows
Defined in:
lib/sakai-cle-test-api/data_objects/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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>"
  }
  options = defaults.merge(opts)

  @name = options[:name]
  @description = options[:description]
  @site = options[:site]
  @folder = options[:folder]
  @html = options[:html]
  @site = options[:site]
  raise "You must specify a Site for your HTML Page" if @site==nil
end

Instance Attribute Details

#descriptionObject

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

#folderObject

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

#htmlObject 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

#nameObject 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

#siteObject

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

#urlObject 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

#createObject



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