Module: OnlyofficeDocumentserverTestingFramework::PasswordProtectedHelper

Included in:
Management
Defined in:
lib/onlyoffice_documentserver_testing_framework/test_instance_docs/management/password_protected_helper.rb

Overview

Helper to handle password protected files

Instance Method Summary collapse

Instance Method Details

#handle_password_protection(password) ⇒ Object

Handle some more alert dialogs



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/management/password_protected_helper.rb', line 24

def handle_password_protection(password)
  return unless @instance.selenium.element_visible?(xpath_input_password)

  @instance.webdriver.webdriver_error("Cannot open file with password: `#{password}`") if incorrect_password_shown?

  # This is stage way to enter password, but
  # for some reason entering it and clicking on Ok no longer works
  # Not sure if it is webdriver or DocumentServer issue
  # Current variant should work rather ok
  @instance.selenium.send_keys_to_focused_elements("#{password}\n")
  OnlyofficeLoggerHelper.log('Entered password in password dialog and pressed enter')
end

#incorrect_password_shown?Boolean

Returns check if incorrect password warning is shown.

Returns:

  • (Boolean)

    check if incorrect password warning is shown



17
18
19
20
21
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/management/password_protected_helper.rb', line 17

def incorrect_password_shown?
  error_xpath = "#{xpath_input_password}/.."

  @instance.webdriver.get_attribute(error_xpath, 'class').include?('error')
end

#xpath_input_passwordString

Returns xpath of password input.

Returns:

  • (String)

    xpath of password input



7
8
9
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/management/password_protected_helper.rb', line 7

def xpath_input_password
  '//div[@id="id-password-txt"]//input'
end

#xpath_ok_passwordString

Returns xpath of ok in protected file dialog.

Returns:

  • (String)

    xpath of ok in protected file dialog



12
13
14
# File 'lib/onlyoffice_documentserver_testing_framework/test_instance_docs/management/password_protected_helper.rb', line 12

def xpath_ok_password
  "#{xpath_input_password}/../../../../../..//button[@result='ok']"
end