From e64c31ef448f53f5f3067460487e84068a96e3b0 Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 24 Sep 2012 19:24:56 +0200 Subject: [PATCH] Get the confirm page for transfer --- modules/ing/browser.py | 6 +++- modules/ing/pages/login.py | 1 - modules/ing/pages/transfer.py | 55 ++++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/modules/ing/browser.py b/modules/ing/browser.py index ec861ae7..fb97dd2f 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -30,7 +30,8 @@ __all__ = ['Ing'] class Ing(BaseBrowser): DOMAIN = 'secure.ingdirect.fr' PROTOCOL = 'https' - DEBUG_HTTP = True + DEBUG_HTTP = False + #DEBUG_HTTP = True ENCODING = None # refer to the HTML encoding PAGES = {'.*displayTRAccountSummary.*': AccountsList, '.*displayLogin.jsf': LoginPage, @@ -138,9 +139,12 @@ class Ing(BaseBrowser): self.logger.debug('Found %s ' % destination.id) if destination.id == recipient: found = True + recipient = destination break if found: + self.openurl('/protected/pages/cc/transfer/transferManagement.jsf', self.page.buildonclick(recipient, account)) self.page.transfer(recipient, amount, reason) + self.location('/protected/pages/cc/transfer/create/transferCreateValidation.jsf') if not self.is_on_page(TransferConfirmPage): raise TransferError("Recipient not found") else: diff --git a/modules/ing/pages/login.py b/modules/ing/pages/login.py index df59cba9..e07f3b59 100644 --- a/modules/ing/pages/login.py +++ b/modules/ing/pages/login.py @@ -105,7 +105,6 @@ class LoginPage(BasePage): def error(self): error = self.document.find('//span[@class="error"]') return error is not None - class LoginPage2(BasePage): def on_loaded(self): diff --git a/modules/ing/pages/transfer.py b/modules/ing/pages/transfer.py index 687c7e3a..a06a6bf2 100644 --- a/modules/ing/pages/transfer.py +++ b/modules/ing/pages/transfer.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . +import urllib from weboob.capabilities.bank import Recipient, AccountNotFound from weboob.tools.browser import BasePage @@ -41,6 +42,7 @@ class TransferPage(BasePage): recipient = Recipient() recipient.id = id recipient.label = name + recipient._type = "int" yield recipient # Second, externals recipients @@ -51,6 +53,7 @@ class TransferPage(BasePage): recipient = Recipient() recipient.id = option.attrib['value'] recipient.label = option.text + recipient._type = "ext" yield recipient def ischecked(self, account): @@ -83,9 +86,59 @@ class TransferPage(BasePage): self.browser.controls.append(ClientForm.TextControl('text', 'transfer_form:valide', {'value': "transfer_form:valide"})) self.browser['transfer_form:validateDoTransfer'] = "needed" self.browser['transfer_form:transferAmount'] = str(amount) - self.browser['transfer_recipient_radio'] = [recipient] + if recipient._type == "int": + self.browser['transfer_recipient_radio'] = [recipient.id] + else: + self.browser['transfer_form:externalAccounts'] = [recipient.id] self.browser.submit() + def buildonclick(self, recipient, account): + javax = self.document.xpath('//input[@id="javax.faces.ViewState"]')[0].attrib['value'] + if recipient._type == "ext": + select = self.document.xpath('//select[@id="transfer_form:externalAccounts"]')[0] + onclick = select.attrib['onchange'] + print onclick + params = onclick.split(',')[6].split('{')[1] + idparam = params.split("'")[1] + param = params.split("'")[3] + request = self.browser.buildurl('', ("AJAXREQUEST", "transfer_form:transfer_radios_form"), + ("transfer_form:generalMessages", ""), + ("transfer_issuer_radio", account.id[3:]), + ("transfer_form:externalAccounts", recipient.id), + ("transfer_date", 0), + ("transfer_form:transferAmount", ""), + ("transfer_form:transferMotive", ""), + ("transfer_form:validateDoTransfer", "needed"), + ("transfer_form", "transfer_form"), + ("autoScrol", ""), + ("javax.faces.ViewState", javax), + (idparam, param)) + request = request[1:] # remove the "?" + return request + elif recipient._type == "int": + for input in self.document.xpath('//input[@value=%s]' % recipient.id): + if input.attrib['name'] == "transfer_recipient_radio": + onclick = input.attrib['onclick'] + break + params = onclick.split(',')[6].split('{')[1] + idparam = params.split("'")[1] + param = params.split("'")[3] + request = self.browser.buildurl('', ("AJAXREQUEST", "transfer_form:transfer_radios_form"), + ("transfer_form:generalMessages", ""), + ('transfer_issuer_radio', account.id[3:]), + ("transfer_recipient_radio", recipient.id), + ("transfer_form:externalAccounts", "na"), + ("transfer_date", 0), + ("transfer_form:transferAmount", ""), + ("transfer_form:transferMotive", ""), + ("transfer_form:AvalidateDoTransfer", "needed"), + ("transfer_form", "transfer_form"), + ("autoScroll", ""), + ("javax.faces.ViewState", javax), + (idparam, param)) + request = request[1:] + return request + class TransferConfirmPage(BasePage): def on_loaded(self):