Module: DocTestSiteServerHelper

Included in:
DocTestSiteFunctions
Defined in:
lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions/doc_test_site_server_helper.rb

Overview

Helper method to fetch server url

Instance Method Summary collapse

Instance Method Details

#fetch_docserverserver_url(example_url) ⇒ String

Returns url of docserver.

Returns:

  • (String)

    url of docserver



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions/doc_test_site_server_helper.rb', line 6

def fetch_docserverserver_url(example_url)
  page_data = URI.parse(example_url).open.read
  html_doc = Nokogiri::HTML(page_data)
  load_scripts_data = html_doc.xpath('//*[@id="loadScripts"]')
  return nil if load_scripts_data.empty?

  script_html = load_scripts_data.attr('data-docs')
  server_from_cache_script_html(script_html)
rescue RuntimeError => e
  OnlyofficeLoggerHelper.log("Failed to fetch_docserverserver_url with #{e}")
  nil
end