Module: OnlyofficeWebdriverWrapper::WebdriverAlertHelper

Included in:
WebDriver
Defined in:
lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_alert_helper.rb

Overview

Methods for working with alerts

Constant Summary collapse

NO_ALERT_EXCEPTIONS =

Exception which happens if there is no alerts

[Errno::ECONNREFUSED,
Net::ReadTimeout,
Selenium::WebDriver::Error::InvalidSessionIdError,
Selenium::WebDriver::Error::NoSuchAlertError].freeze

Instance Method Summary collapse

Instance Method Details

#alert_confirmvoid

This method returns an undefined value.

Confirm current alert



16
17
18
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_alert_helper.rb', line 16

def alert_confirm
  @driver.switch_to.alert.accept if alert_exists?
end

#alert_exists?Boolean

Check if alert exists

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_alert_helper.rb', line 22

def alert_exists?
  @driver.switch_to.alert.text
  true
rescue *NO_ALERT_EXCEPTIONS
  false
end

#alert_textString

Get alert text

Returns:

  • (String)

    text inside alert



31
32
33
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_alert_helper.rb', line 31

def alert_text
  @driver.switch_to.alert.text
end