Class: OnlyofficeDocumentserverTestingFramework::TxtOptions

Inherits:
Object
  • Object
show all
Extended by:
Gem::Deprecate
Includes:
SeleniumWrapper
Defined in:
lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb

Overview

Class for TXT export window

Direct Known Subclasses

CsvOption

Instance Method Summary collapse

Methods included from SeleniumWrapper

#button_disabled?, #button_menu_active?, #button_menu_open?, #button_pressed?, #click_on_button, #click_on_displayed_button, #click_on_of_several_by_display_button, #frame_count_addition, #get_attribute, #line_checked?, #line_enabled?, #menu_disabled?, #remove_element, #select_frame, #selenium_functions, #visible?

Methods included from SeleniumWrapperJsErrors

#console_errors, #error_ignored?, #fail_if_console_error, #ignored_errors

Constructor Details

#initialize(instance) ⇒ TxtOptions

Returns a new instance of TxtOptions.



8
9
10
11
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 8

def initialize(instance)
  @instance = instance
  @xpath_codepage_selector = '//*[contains(text(), "TXT")]/../..//div[@id="id-codepages-combo"]'
end

Instance Method Details

#click_on_cancelnil

Click on cancel button

Returns:

  • (nil)


38
39
40
41
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 38

def click_on_cancel
  click_on_button '//button[@result="cancel"]'
  OnlyofficeLoggerHelper.log('Click on CANCEL button')
end

#click_on_oknil

Click on ok button

Returns:

  • (nil)


31
32
33
34
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 31

def click_on_ok
  click_on_button '//button[@result="ok"]'
  OnlyofficeLoggerHelper.log('Click on OK button')
end

#close_warning_loose_datanil

Close warning about loose data

Returns:

  • (nil)


111
112
113
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 111

def close_warning_loose_data
  click_on_ok if loose_data_warning_present?
end

#dialog_window_opened?True, False

Returns is txt options dialog opened.

Returns:

  • (True, False)

    is txt options dialog opened



16
17
18
19
20
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 16

def dialog_window_opened?
  visible = visible? @xpath_codepage_selector
  OnlyofficeLoggerHelper.log("Codepage option window is opened: #{visible}")
  visible
end

#encodingBoundComboBoxUl

Control to set encoding

Returns:

  • (BoundComboBoxUl)


45
46
47
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 45

def encoding
  BoundComboBoxUl.new(@instance, @xpath_codepage_selector, nil, 'span')
end

#encoding_select(encoding_name) ⇒ Object

Parameters:

  • encoding_name (String)

    like as ‘French Canadian (DOS)’



86
87
88
89
90
91
92
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 86

def encoding_select(encoding_name)
  encoding.open
  # TODO: Replace with correct include after find out https://github.com/ONLYOFFICE/testing-documentserver/pull/2006
  list_item_number = encoding.items_text.index { |item| item.include?(encoding_name) } + 1
  scroll_encoding_list_to list_item_number
  encoding.select_by_number list_item_number
end

#loose_data_warning_present?True, False

Returns is loose data warning visible.

Returns:

  • (True, False)

    is loose data warning visible



23
24
25
26
27
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 23

def loose_data_warning_present?
  visible = visible? '//*[contains(@class, "asc-window modal alert")]'
  OnlyofficeLoggerHelper.log("Codepage option window is opened: #{visible}")
  visible
end

#scroll_encoding_list_to(list_item_number) ⇒ nil

List encoding list to item number

Parameters:

  • list_item_number (Integer)

    item to scroll

Returns:

  • (nil)


52
53
54
55
56
57
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 52

def scroll_encoding_list_to(list_item_number)
  selenium_functions(:scroll_list_by_pixels,
                     "//*[@id='id-codepages-combo']/span/ul",
                     (list_item_number - 1) * 25)
  OnlyofficeLoggerHelper.log("Scroll to #{list_item_number} element")
end

#txt_options=(encoding_to_set = nil) ⇒ nil Also known as: set_txt_options

Set options in txt window

Parameters:

  • encoding_to_set (String) (defaults to: nil)

    encoding to set

Returns:

  • (nil)


97
98
99
100
101
102
103
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 97

def txt_options=(encoding_to_set = nil)
  return unless dialog_window_opened?

  encoding_to_set = encoding.items_text.last if encoding_to_set.nil?
  encoding_select encoding_to_set
  click_on_ok
end

#wait_optionsnil

Wait for csv options to show

Returns:

  • (nil)


76
77
78
79
80
81
82
83
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 76

def wait_options
  counter = 0
  while !dialog_window_opened? && counter < 30
    sleep 1
    counter += 1
  end
  @instance.webdriver.webdriver_error 'Wait for TXT options failed' if counter == 30
end

#wait_warningnil

Wait for loose data warning to show

Returns:

  • (nil)


65
66
67
68
69
70
71
72
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/doc_editor/doc_editor_windows/txt_options.rb', line 65

def wait_warning
  counter = 0
  while !loose_data_warning_present? && counter < 30
    sleep 1
    counter += 1
  end
  @instance.webdriver.webdriver_error 'Wait for TXT warning failed' if counter == 30
end