From 4b90fd787ba40b30482fe22cdd19c53f3e72152a Mon Sep 17 00:00:00 2001 From: AaronJamesY Date: Sun, 12 Feb 2017 22:16:34 +0000 Subject: [PATCH] Fixed balance logic for normal accounts --- .../AccountManagers/LloydsAccountManager.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/BankingBot/ActionManagers/AccountManagers/LloydsAccountManager.cs b/BankingBot/ActionManagers/AccountManagers/LloydsAccountManager.cs index dae8295..8aa7381 100644 --- a/BankingBot/ActionManagers/AccountManagers/LloydsAccountManager.cs +++ b/BankingBot/ActionManagers/AccountManagers/LloydsAccountManager.cs @@ -39,8 +39,20 @@ namespace BankingBot.ActionManagers.AccountManagers account.AccountNumber = container.FindElement(By.ClassName("account-number")).Text; account.SortCode = container.FindElement(By.CssSelector("dd[aria-label='12 34 56']")).Text; - var balance = 0m; - var balanceTxt = container.FindElement(By.ClassName("balance")).FindElement(By.TagName("span")).Text; + string balanceTxt; + decimal balance; + + // Split logic for getting Current Account AVAILABLE balance + // or a normal account's balance + try + { + balanceTxt = container.FindElement(By.ClassName("available-balance")).Text; + } + catch (NoSuchElementException) + { + balanceTxt = container.FindElement(By.ClassName("balance")).FindElement(By.TagName("span")).Text; + } + decimal.TryParse(balanceTxt, NumberStyles.Currency, new CultureInfo("en-GB"), out balance); account.Balance = balance;