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, 0, 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.
- #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, 0, 0)) ⇒ Array<String>
Returns list of supported languages.
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 232 def self.supported_languages(version = OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(8, 0, 0)) file = if version >= OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(8, 0) 'doc_test_site_languages_after_8_0.list' elsif version >= OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(7, 4) 'doc_test_site_languages_after_7_4.list' elsif version >= OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(7, 3) 'doc_test_site_languages_after_7_3.list' elsif version >= OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(7, 2) 'doc_test_site_languages_after_7_2.list' elsif version >= OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(7, 1) 'doc_test_site_languages_after_7_1.list' elsif version >= OnlyofficeDocumentserverTestingFramework::DocumentServerVersion.new(6, 2) 'doc_test_site_languages_after_6_2.list' else 'doc_test_site_languages_before_6_2.list' 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.
193 194 195 196 197 198 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 193 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
157 158 159 160 161 162 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 157 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?.
165 166 167 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 165 def file_list_opened? @instance.selenium.element_visible?(@xpath_create_doc) end |
#file_uploaded? ⇒ Boolean
Check if file uploaded
125 126 127 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 125 def file_uploaded? @instance.selenium.element_visible?(@xpath_begin_view) end |
#go_to_healthcheck ⇒ Nothing
221 222 223 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 221 def go_to_healthcheck @instance.webdriver.open("#{@instance.user_data.portal}healthcheck") end |
#healthcheck ⇒ HealthcheckPage
Returns page of healthcheck.
226 227 228 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 226 def healthcheck @healthcheck = HealthcheckPage.new(@instance) end |
#open_file_in ⇒ Object
help-method to #open_file_in_editor and #open_file_in_viewer
130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 130 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
145 146 147 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 145 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
151 152 153 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 151 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
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 202 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.
185 186 187 188 189 190 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 185 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.
170 171 172 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 170 def uploaded_file_count @instance.selenium.get_element_count(@xpath_file_entry) end |
#uploaded_file_list ⇒ DocTestFileLIst
Returns get file list.
175 176 177 178 179 180 181 182 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 175 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
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_test_site_functions.rb', line 112 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(@xpath_editor_scripts_step, 'class').include?('done') sleep 1 check_error end @instance.selenium.webdriver_error('File not finished for loading scripts for 100 seconds') end |