Class: ScbEasy::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/scb_easy/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username:, password:) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
# File 'lib/scb_easy/client.rb', line 12

def initialize(username:, password:)
  @username = username
  @password = password
  @driver = self.class.driver
end

Class Method Details

.driverObject



5
6
7
8
9
10
# 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

Instance Method Details

#savingsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/scb_easy/client.rb', line 18

def savings
  begin
    header = @driver.find_element(id: 'DataProcess_imgHeader')

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

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