Class: DocTestSiteFunctions
- Inherits:
-
Object
- Object
- DocTestSiteFunctions
- Extended by:
- DocTestSiteServerHelper
- Includes:
- OnlyofficeDocumentserverTestingFramework::FileReopenHelper, OnlyofficeDocumentserverTestingFramework::PasswordProtectedConversionHelper, PageObject
- Defined in:
- lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb
Overview
Class to work with test examples
Class Method Summary collapse
-
.supported_languages(version = OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(8, 3, 0)) ⇒ Array<String>
List of supported languages.
Instance Method Summary collapse
-
#check_error ⇒ Nothing
Check for any error in loading process and raise it.
-
#create_a_file_with_sample ⇒ Checkbox
Create a file filled with sample content.
-
#current_document_storage_url ⇒ String
Get url of document which opened in editor.
-
#doc_test_site? ⇒ true, false
Check if current site is DocTestSite.
-
#file_list_opened? ⇒ True, False
Is on file list page now?.
-
#file_uploaded? ⇒ Boolean
Check if file uploaded.
-
#final_loading_step_xpath ⇒ Nothing
Checks if Loading editor scripts step of file upload is present.
- #go_to_healthcheck ⇒ Nothing
-
#healthcheck ⇒ HealthcheckPage
Page of healthcheck.
-
#initialize(instance, edit_modes_indexes = default_modes_indexes) ⇒ DocTestSiteFunctions
constructor
A new instance of DocTestSiteFunctions.
-
#open_file_in ⇒ Object
help-method to #open_file_in_editor and #open_file_in_viewer.
-
#open_file_in_editor ⇒ Object
Click on Edit Button and wait opening Editor Return result of the opening Editor.
-
#open_file_in_viewer ⇒ Object
Click on View Button and wait opening Viewer Return result of the opening Viewer.
-
#open_sample_document(format = :document, wait_to_load: true) ⇒ String
Perform creating sample document.
-
#reload ⇒ Nothing
reload the page.
-
#save_in_original_format ⇒ Checkbox
Save in original format checkbox.
-
#upload_file(file_path) ⇒ Object
Upload file to portal.
-
#uploaded_file_count ⇒ Integer
Count of uploaded files.
-
#uploaded_file_list ⇒ DocTestFileLIst
Get file list.
-
#wait_conversion ⇒ Nothing
Waits until file converts.
-
#wait_load ⇒ Nothing
Waiting for load of page.
-
#wait_loading_file ⇒ Nothing
Waits until file converts.
-
#wait_loading_scripts ⇒ Nothing
Waits until scripts loads.
Methods included from DocTestSiteServerHelper
Methods included from OnlyofficeDocumentserverTestingFramework::PasswordProtectedConversionHelper
#handle_password_protection, #incorrect_password_shown?, #wait_to_check_password, #xpath_enter_password, #xpath_input_password, #xpath_password_error
Methods included from OnlyofficeDocumentserverTestingFramework::FileReopenHelper
Constructor Details
#initialize(instance, edit_modes_indexes = default_modes_indexes) ⇒ DocTestSiteFunctions
Returns a new instance of DocTestSiteFunctions.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 18 def initialize(instance, edit_modes_indexes = default_modes_indexes) super(instance.webdriver.driver) @instance = instance @xpath_begin_view = '//*[@id="beginView"]' @xpath_file_loading_step = '//*[@id="step1"]' @xpath_conversion_step = '//*[@id="step2"]' @xpath_editor_scripts_step = '//*[@id="step3"]' @xpath_file_entry = '//*[@class="stored-list"]//table/tbody/tr' @xpath_create_doc = '//*[contains(@class, "try-editor document")]|' \ '//*[contains(@class, "try-editor word")]' @xpath_create_workbook = '//*[contains(@class, "try-editor spreadsheet")]|' \ '//*[contains(@class, "try-editor cell")]' @xpath_create_presentation = '//*[contains(@class, "try-editor presentation")]|' \ '//*[contains(@class, "try-editor slide")]' @edit_modes_indexes = edit_modes_indexes end |
Class Method Details
.supported_languages(version = OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(8, 3, 0)) ⇒ Array<String>
Returns list of supported languages.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 240 def self.supported_languages(version = OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(8, 3, 0)) version_class = OnlyofficeDocumentserverTestingFramework::DocumentServerVersion version_mappings = [ [version_class.new(8, 2), 'doc_test_site_languages_after_8_3.list'], [version_class.new(8, 2), 'doc_test_site_languages_after_8_2.list'], [version_class.new(8, 1), 'doc_test_site_languages_after_8_1.list'], [version_class.new(8, 0), 'doc_test_site_languages_after_8_0.list'], [version_class.new(7, 4), 'doc_test_site_languages_after_7_4.list'], [version_class.new(7, 3), 'doc_test_site_languages_after_7_3.list'], [version_class.new(7, 2), 'doc_test_site_languages_after_7_2.list'], [version_class.new(7, 1), 'doc_test_site_languages_after_7_1.list'], [version_class.new(6, 2), 'doc_test_site_languages_after_6_2.list'] ] file = 'doc_test_site_languages_before_6_2.list' version_mappings.each do |ver, file_name| if version >= ver file = file_name break end end File.readlines("#{File.('..', __dir__)}" \ '/test_instance_docs/doc_test_site_functions/' \ "languages_list/#{file}") .map(&:strip) end |
Instance Method Details
#check_error ⇒ Nothing
Check for any error in loading process and raise it
72 73 74 75 76 77 78 79 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 72 def check_error = @instance.selenium.get_text('//*[@class="error-message"]/span', false) return if .empty? @instance.selenium.webdriver_error('Error while uploading document. ' \ "Error message: #{}") end |
#create_a_file_with_sample ⇒ Checkbox
Returns Create a file filled with sample content.
201 202 203 204 205 206 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 201 def create_a_file_with_sample checkbox = CheckBox.new(@instance) checkbox.xpath = '//*[@id="createSample"]' checkbox.count_of_frame = 0 checkbox end |
#current_document_storage_url ⇒ String
Get url of document which opened in editor
165 166 167 168 169 170 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 165 def current_document_storage_url page_source = @instance.selenium.page_source url_line = page_source.scan(/"?url"?: ".*$/).first pretty_url = url_line.delete('"').gsub('url: ', '').chop pretty_url.gsub(/&useraddress=.*/, '') end |
#doc_test_site? ⇒ true, false
Check if current site is DocTestSite
52 53 54 55 56 57 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 52 def doc_test_site? sleep(1) # TODO: remove after update to Chromedriver 80 result = @instance.selenium.element_present?(@xpath_begin_view) OnlyofficeLoggerHelper.log("Current server is a doc_test_site: #{result}") result end |
#file_list_opened? ⇒ True, False
Returns is on file list page now?.
173 174 175 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 173 def file_list_opened? @instance.selenium.element_visible?(@xpath_create_doc) end |
#file_uploaded? ⇒ Boolean
Check if file uploaded
133 134 135 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 133 def file_uploaded? @instance.selenium.element_visible?(@xpath_begin_view) end |
#final_loading_step_xpath ⇒ Nothing
Checks if Loading editor scripts step of file upload is present
112 113 114 115 116 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 112 def final_loading_step_xpath return @xpath_editor_scripts_step if @instance.selenium.element_visible?(@xpath_editor_scripts_step) @xpath_conversion_step end |
#go_to_healthcheck ⇒ Nothing
229 230 231 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 229 def go_to_healthcheck @instance.webdriver.open("#{@instance.user_data.portal}healthcheck") end |
#healthcheck ⇒ HealthcheckPage
Returns page of healthcheck.
234 235 236 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 234 def healthcheck @healthcheck = HealthcheckPage.new(@instance) end |
#open_file_in ⇒ Object
help-method to #open_file_in_editor and #open_file_in_viewer
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 138 def open_file_in result = 'Unknown' if file_uploaded? yield sleep 5 @instance.selenium.close_tab @instance.selenium.switch_to_main_tab result = @instance.management.wait_for_operation_with_round_status_canvas sleep 3 # just for sure end result end |
#open_file_in_editor ⇒ Object
Click on Edit Button and wait opening Editor Return result of the opening Editor
153 154 155 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 153 def open_file_in_editor open_file_in { @instance.selenium.click_on_locator('//*[@id="beginEdit"]') } end |
#open_file_in_viewer ⇒ Object
Click on View Button and wait opening Viewer Return result of the opening Viewer
159 160 161 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 159 def open_file_in_viewer open_file_in { @instance.selenium.click_on_locator(@xpath_begin_view) } end |
#open_sample_document(format = :document, wait_to_load: true) ⇒ String
Perform creating sample document
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 210 def open_sample_document(format = :document, wait_to_load: true) case format when :document @instance.selenium.click_on_locator(@xpath_create_doc) when :spreadsheet @instance.selenium.click_on_locator(@xpath_create_workbook) when :presentation @instance.selenium.click_on_locator(@xpath_create_presentation) else @instance.webdriver.webdriver_error("Unknown file type for open_sample_document(#{format})") end return unless wait_to_load @instance.selenium.close_tab @instance.selenium.switch_to_main_tab @instance.management.wait_for_operation_with_round_status_canvas end |
#reload ⇒ Nothing
reload the page
45 46 47 48 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 45 def reload @instance.webdriver.refresh wait_load end |
#save_in_original_format ⇒ Checkbox
Returns save in original format checkbox.
193 194 195 196 197 198 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 193 def save_in_original_format checkbox = CheckBox.new(@instance) checkbox.xpath = '//*[@id="checkOriginalFormat"]' checkbox.count_of_frame = 0 checkbox end |
#upload_file(file_path) ⇒ Object
Upload file to portal
61 62 63 64 65 66 67 68 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 61 def upload_file(file_path) file_path_absolute = file_path.gsub('~', Dir.home) @instance.selenium.type_to_locator('//*[@id="fileupload"]', file_path_absolute, false, false, false, true) wait_loading_file wait_conversion wait_loading_scripts true end |
#uploaded_file_count ⇒ Integer
Returns count of uploaded files.
178 179 180 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 178 def uploaded_file_count @instance.selenium.get_element_count(@xpath_file_entry) end |
#uploaded_file_list ⇒ DocTestFileLIst
Returns get file list.
183 184 185 186 187 188 189 190 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 183 def uploaded_file_list file_list = (0...uploaded_file_count).map do |current_file_number| DocTestSiteFileListEntry.new(@instance, "#{@xpath_file_entry}[#{current_file_number + 1}]", @edit_modes_indexes) end DocTestFileList.new(file_list) end |
#wait_conversion ⇒ Nothing
Waits until file converts
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 96 def wait_conversion 100.times do |current_time| OnlyofficeLoggerHelper.log("Waiting for file conversion for #{current_time} seconds") return true if @instance.selenium.get_attribute(@xpath_conversion_step, 'class').include?('done') if @instance.selenium.element_visible?(xpath_input_password) handle_password_protection(@instance.management.password) end sleep 1 check_error end @instance.selenium.webdriver_error('File not finished for conversion for 100 seconds') end |
#wait_load ⇒ Nothing
Waiting for load of page
37 38 39 40 41 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 37 def wait_load @instance.webdriver.wait_until do doc_test_site? end end |
#wait_loading_file ⇒ Nothing
Waits until file converts
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 83 def wait_loading_file 100.times do |current_time| OnlyofficeLoggerHelper.log("Waiting for file loading for #{current_time} seconds") return true if @instance.selenium.get_attribute(@xpath_file_loading_step, 'class').include?('done') sleep 1 check_error end @instance.selenium.webdriver_error('File not finished for loading scripts for 100 seconds') end |
#wait_loading_scripts ⇒ Nothing
Waits until scripts loads
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 120 def wait_loading_scripts 100.times do |current_time| OnlyofficeLoggerHelper.log("Waiting for editors scripts load for #{current_time} seconds") return true if @instance.selenium.get_attribute(final_loading_step_xpath, 'class').include?('done') sleep 1 check_error end @instance.selenium.webdriver_error('File not finished for loading scripts for 100 seconds') end |