boq_com_au 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +19 -0
- data/README.md +3 -2
- data/boq_com_au.gemspec +1 -1
- data/lib/BoqComAu/Account.rb +18 -9
- data/lib/BoqComAu/VERSION.rb +1 -1
- data/test/BoqComAu/Account_test.rb +33 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a6bd6f8191c055420474e1a4b84ae6f47bcf8dd52820bae41af4a7824b8628c
|
|
4
|
+
data.tar.gz: 7571fc67a6a508a8737aca010f804a2d1dc47c3771f553d987f5be5cc7295922
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe1c612be9bfdf6873a902577a89c33c08b0eb9a1e188892b49a600f0a5625eaa49c7f1a459e909767e9d325ca504593d295be81a7351dd04064d55e882407e2
|
|
7
|
+
data.tar.gz: 1877660bd84ca7c351904efc98b17c9618b0f7bbbe7eed7fbacbb2d5ba8aab3dcf75be5dd52d3aac7db867239a734fa23eefd82da5c4da49cb4fbdab7ed9c551
|
data/CHANGELOG
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
## 20261115
|
|
4
4
|
|
|
5
|
+
0.5.0: ~ BoqComAu::Account::PAGE_SELECTORS: /logged_out_xpath/logged_out_selector/, as WebAccount 0.9.0's.
|
|
6
|
+
|
|
7
|
+
1. ~ boq_com_au.gemspec: webaccount /'~> 0.8'/'~> 0.9'/
|
|
8
|
+
2. ~ BoqComAu::Account::PAGE_SELECTORS: /logged_out_xpath: '...'/logged_out_selector: {xpath: '...'}/, logged_out_xpath going in WebAccount 0.10.0.
|
|
9
|
+
3. ~ test/BoqComAu/Account_test.rb: The logged-out selector is BOQ's where none is given, and one set after construction wins over it.
|
|
10
|
+
4. ~ README.md: The setters win over PAGE_SELECTORS, as the keywords do.
|
|
11
|
+
5. ~ BoqComAu::VERSION: /0.4.1/0.5.0/
|
|
12
|
+
|
|
13
|
+
0.4.1: ~ BoqComAu::Account#login and #download_transactions name every argument missing at once, as an ArgumentError.
|
|
14
|
+
|
|
15
|
+
1. + BoqComAu::Account#validate_args
|
|
16
|
+
2. + BoqComAu::Account#login: Calls validate_args(username:, password:), then WebAccount#login.
|
|
17
|
+
3. - BoqComAu::Account#username, #password: WebAccount's readers are used, nil where not given.
|
|
18
|
+
4. ~ BoqComAu::Account#download_transactions: Calls validate_args(account_number:).
|
|
19
|
+
5. ~ test/BoqComAu/Account_test.rb: One missing and both missing are named by login, given to new or to login itself; a nil account_number is named by download_transactions; username and password are nil where not given.
|
|
20
|
+
6. ~ README.md, Account.rb's notes: login raises ArgumentError naming every one missing.
|
|
21
|
+
7. ~ Account.rb's notes: Chosen, which draws BOQ's dropdowns, is said to be a JavaScript library, as otherwise it reads as the word "chosen".
|
|
22
|
+
8. ~ BoqComAu::VERSION: /0.4.0/0.4.1/
|
|
23
|
+
|
|
5
24
|
0.4.0: - BoqComAu::Account#initialize: Now uses superclass WebAccount.
|
|
6
25
|
|
|
7
26
|
1. ~ boq_com_au.gemspec: webaccount /'~> 0.7'/'~> 0.8'/
|
data/README.md
CHANGED
|
@@ -58,7 +58,7 @@ The username is the Customer Access Number. It and the password are given, or se
|
|
|
58
58
|
boq_account = BoqComAu::Account.new(username: customer_access_number, password: password)
|
|
59
59
|
boq_account.username, boq_account.password = customer_access_number, password
|
|
60
60
|
```
|
|
61
|
-
Where either is missing, `login`
|
|
61
|
+
Where either is missing, `login` raises ArgumentError before starting the browser, naming every one missing.
|
|
62
62
|
|
|
63
63
|
### The browser
|
|
64
64
|
|
|
@@ -79,9 +79,10 @@ Where BOQ asks for a one-time code after logging on, `login` waits up to 30 seco
|
|
|
79
79
|
|
|
80
80
|
The selectors were taken from the live site. BOQ's ids are generated, so things are found by their labels and text, and a change to the wording of the site will break it.
|
|
81
81
|
|
|
82
|
-
Each key of `BoqComAu::Account::PAGE_SELECTORS` is also a keyword of `new`, which wins over BOQ's, so as a
|
|
82
|
+
Each key of `BoqComAu::Account::PAGE_SELECTORS` is also a keyword of `new`, and has a setter, either of which wins over BOQ's, so as a selector which has changed can be given without waiting for a new version:
|
|
83
83
|
```ruby
|
|
84
84
|
BoqComAu::Account.new(login_page_submit_button_selector: {id: 'btnLogOn'})
|
|
85
|
+
boq_account.logged_out_selector = {id: 'btnLogOn'}
|
|
85
86
|
```
|
|
86
87
|
|
|
87
88
|
The tests cover only what doesn't depend on BOQ's site.
|
data/boq_com_au.gemspec
CHANGED
data/lib/BoqComAu/Account.rb
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
# 1. The login page's ids and names (id4, 8, ...) appear to be generated, so the fields are found by their labels.
|
|
6
6
|
# 2. The ids and names after login (id121, 74, ...) appear to be generated too, so TRANSACTIONS_SELECTORS find things by their text.
|
|
7
7
|
# 3. BankFast's links are javascript:void(0) where they aren't the session's key and a callback number, and some, such as Transaction History, are in a menu which is closed. A link which isn't displayed is clicked by JavaScript.
|
|
8
|
-
# 4. Dropdowns are Chosen
|
|
8
|
+
# 4. Dropdowns are drawn by Chosen, a JavaScript library, which hides the select and draws its own: <select id>_chosen, opened by its a.chosen-single and chosen from its li.active-result. A select which is displayed is used as it is.
|
|
9
9
|
# 5. Where a one-time code is asked for after logging on, login() waits default_wait_timeout seconds for it to be entered by hand.
|
|
10
10
|
# 6. The browser, Chrome or Firefox, is WebAccount's: given a profile_directory, it's started with that profile, kept between runs, so as the bank sees a returning browser rather than a fresh automated one. It downloads into download_directory without asking, and opens nothing it downloads.
|
|
11
|
-
# 7. A username or password not given stops login
|
|
11
|
+
# 7. A username or password not given stops login before the browser is started, naming every one missing.
|
|
12
12
|
# 8. BOQ names the exported file after the account number and the date, as 12345678_20261103.csv, and the browser numbers a second download of the same name; so the newest finished CSV file to appear in download_directory once Download is clicked is taken to be it.
|
|
13
13
|
# 9. Dates are BOQ's own, as shown on choosing the account, unless a period or a date is given; then they're set under Advanced Search and searched on before exporting.
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ module BoqComAu
|
|
|
23
23
|
login_page_password_field_selector: {xpath: '//input[@id=//label[normalize-space()="Password"]/@for]'},
|
|
24
24
|
login_page_submit_button_selector: {id: 'btnSignIn'},
|
|
25
25
|
logout_button_selector: {xpath: '//a[contains(translate(normalize-space(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "log off")]'},
|
|
26
|
-
|
|
26
|
+
logged_out_selector: {xpath: '//a[normalize-space()="Log On Again"] | //input[@id="btnSignIn"]'}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
TRANSACTIONS_SELECTORS = {
|
|
@@ -37,16 +37,14 @@ module BoqComAu
|
|
|
37
37
|
download_button: {xpath: '//*[self::a or self::button][normalize-space()="Download"] | //input[@value="Download"]'}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
def username
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def password
|
|
45
|
-
@password || raise("No password: it's given as password:.")
|
|
40
|
+
def login(username: nil, password: nil)
|
|
41
|
+
validate_args(username: username || self.username, password: password || self.password)
|
|
42
|
+
super
|
|
46
43
|
end
|
|
47
44
|
|
|
48
45
|
# period is :all, the last year, or :last_month. Without it, from_date and to_date, either of which defaults to a year ago and today respectively where the other is given. Returns the name of the CSV file downloaded.
|
|
49
46
|
def download_transactions(account_number:, period: nil, from_date: nil, to_date: nil)
|
|
47
|
+
validate_args(account_number: account_number)
|
|
50
48
|
from_date, to_date = dates(period: period, from_date: from_date, to_date: to_date)
|
|
51
49
|
get_transactions_page
|
|
52
50
|
select_bank_account(account_number)
|
|
@@ -59,6 +57,17 @@ module BoqComAu
|
|
|
59
57
|
|
|
60
58
|
private
|
|
61
59
|
|
|
60
|
+
def validate_args(args)
|
|
61
|
+
missing_args = []
|
|
62
|
+
args.each do |arg_name, value|
|
|
63
|
+
missing_args << arg_name unless value
|
|
64
|
+
end
|
|
65
|
+
return if missing_args.empty?
|
|
66
|
+
aggregate_error = missing_args.join(', ')
|
|
67
|
+
copula = missing_args.count > 1 ? 'are' : 'is'
|
|
68
|
+
raise ArgumentError, "#{aggregate_error} #{copula} missing."
|
|
69
|
+
end
|
|
70
|
+
|
|
62
71
|
# page interaction
|
|
63
72
|
|
|
64
73
|
def chosen_list(select_element)
|
data/lib/BoqComAu/VERSION.rb
CHANGED
|
@@ -81,17 +81,34 @@ describe BoqComAu::Account do
|
|
|
81
81
|
_(account.password).must_equal('secret')
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
it "
|
|
84
|
+
it "are nil where they're not given, rather than read from the environment" do
|
|
85
85
|
ENV['BOQ_USERNAME'], ENV['BOQ_PASSWORD'] = 'customer', 'secret'
|
|
86
86
|
account = BoqComAu::Account.new
|
|
87
|
-
_(
|
|
88
|
-
_(
|
|
87
|
+
_(account.username).must_be_nil
|
|
88
|
+
_(account.password).must_be_nil
|
|
89
89
|
ensure
|
|
90
90
|
ENV.delete('BOQ_USERNAME')
|
|
91
91
|
ENV.delete('BOQ_PASSWORD')
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
+
describe "#login" do
|
|
96
|
+
it "names the one missing, before starting the browser" do
|
|
97
|
+
account = BoqComAu::Account.new(username: 'customer')
|
|
98
|
+
_(_{account.login}.must_raise(ArgumentError).message).must_equal('password is missing.')
|
|
99
|
+
_(account.instance_variable_get(:@driver)).must_be_nil
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "names both where both are missing" do
|
|
103
|
+
_(_{BoqComAu::Account.new.login}.must_raise(ArgumentError).message).must_equal('username, password are missing.')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "takes either given to login itself as given" do
|
|
107
|
+
_(_{BoqComAu::Account.new(username: 'customer').login(password: nil)}.must_raise(ArgumentError).message).must_equal('password is missing.')
|
|
108
|
+
_(_{BoqComAu::Account.new.login(username: 'customer')}.must_raise(ArgumentError).message).must_equal('password is missing.')
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
95
112
|
describe "#download_transactions" do
|
|
96
113
|
def account_recording_steps
|
|
97
114
|
account = account_with_driver(stand_in_driver)
|
|
@@ -112,6 +129,12 @@ describe BoqComAu::Account do
|
|
|
112
129
|
account.download_transactions(account_number: '12345678', from_date: '2026-10-01', to_date: '2026-10-31')
|
|
113
130
|
_(steps).must_equal([:get_transactions_page, :select_bank_account, [:enter_dates, '2026-10-01', '2026-10-31'], :search, :export_csv])
|
|
114
131
|
end
|
|
132
|
+
|
|
133
|
+
it "names a missing account number, before going to the transactions page" do
|
|
134
|
+
account, steps = account_recording_steps
|
|
135
|
+
_(_{account.download_transactions(account_number: nil)}.must_raise(ArgumentError).message).must_equal('account_number is missing.')
|
|
136
|
+
_(steps).must_be_empty
|
|
137
|
+
end
|
|
115
138
|
end
|
|
116
139
|
|
|
117
140
|
describe "the browser" do
|
|
@@ -141,6 +164,13 @@ describe BoqComAu::Account do
|
|
|
141
164
|
account = BoqComAu::Account.new
|
|
142
165
|
_(account.send(:login_page_username_field_selector)).must_equal(BoqComAu::Account::PAGE_SELECTORS[:login_page_username_field_selector])
|
|
143
166
|
_(account.send(:logout_button_selector)).must_equal(BoqComAu::Account::PAGE_SELECTORS[:logout_button_selector])
|
|
167
|
+
_(account.logged_out_selector).must_equal({xpath: '//a[normalize-space()="Log On Again"] | //input[@id="btnSignIn"]'})
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it "uses a selector set after construction over BOQ's" do
|
|
171
|
+
account = BoqComAu::Account.new
|
|
172
|
+
account.logged_out_selector = {id: 'btnLogOn'}
|
|
173
|
+
_(account.logged_out_selector).must_equal({id: 'btnLogOn'})
|
|
144
174
|
end
|
|
145
175
|
|
|
146
176
|
it "logs in where told to, a keyword winning over BOQ's selector" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: boq_com_au
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '0.
|
|
32
|
+
version: '0.9'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0.
|
|
39
|
+
version: '0.9'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: minitest
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|