class ScbEasy::Client

Public Class Methods

driver() click to toggle source
# File lib/scb_easy/client.rb, line 5
def self.driver
  return @driver if defined? @driver

  options = Selenium::WebDriver::Chrome::Options.new(args: ['headless'])
  @driver = Selenium::WebDriver.for(:chrome, options: options)
end
new(username:, password:) click to toggle source
# File lib/scb_easy/client.rb, line 12
def initialize(username:, password:)
  @username = username
  @password = password
  @driver = self.class.driver
end

Public Instance Methods

savings() click to toggle source
# File lib/scb_easy/client.rb, line 18
def savings
  begin
    header = @driver.find_element(id: 'DataProcess_imgHeader')

   account_summary unless header.attribute('src').end_with?('acc_sum_hd.gif')
  rescue Selenium::WebDriver::Error::NoSuchElementError
    account_summary
  end

  @driver.
    find_element(xpath: "//*/table[@class='pd_rt_10']/tbody/tr[3]/td[3]").
    text
end

Private Instance Methods

account_summary() click to toggle source
# File lib/scb_easy/client.rb, line 32
        def account_summary
  @driver.get('https://www.scbeasy.com/v1.4/site/presignon/index_en.asp')

  element = @driver.find_element(name: 'LOGIN')

  element.send_keys(@username)

  element = @driver.find_element(name: 'PASSWD')

  element.send_keys(@password)

  element.submit

  # To -> My Accounts
  @driver.find_element(id: 'Img2').click

  # To -> Account Summary
  @driver.find_element(partial_link_text: 'Account Summary').click
end