module OA
  class UploadTrackLicensingPage < OA::BasePage
    page_url "/publishing/uploadtrackpublishing"

    link(:download_template, text: "Excel (.xls) file template")
    file_field(:choose_file, name: "txtUpdateFile")
    button(:upload_button, name: "btnUpload")
    div(:success_message, class: "alertConfirm")
    div(:error_message, id: "err_msg")
    div(:alert_error, id: "exceptional_upload_error")

    def template_url
      download_template_element.element.href
    end

    def upload_file(abs_path)
      fail "file does not exist at path: #{abs_path}" unless File.exist?(abs_path)
      self.choose_file = abs_path
      upload_button
    end
  end
end
