Some browser2 features in transfer pages
This commit is contained in:
parent
839834edf2
commit
af570a856f
2 changed files with 22 additions and 39 deletions
|
|
@ -19,7 +19,7 @@
|
|||
import hashlib
|
||||
|
||||
from weboob.tools.browser2 import LoginBrowser, URL, need_login
|
||||
from weboob.tools.browser import BrowserIncorrectPassword
|
||||
from weboob.tools.browser import BrowserIncorrectPassword, BrokenPageError
|
||||
from weboob.capabilities.bank import Account, TransferError
|
||||
|
||||
from .pages import AccountsList, LoginPage, TitrePage, TitreHistory,\
|
||||
|
|
@ -173,6 +173,9 @@ class IngBrowser(LoginBrowser):
|
|||
else:
|
||||
self.page.confirm(self.password)
|
||||
self.valtransferpage.go()
|
||||
recap = self.page.recap()
|
||||
if len(list(recap)) == 0:
|
||||
raise BrokenPageError('Unable to find confirmation')
|
||||
return self.page.recap()
|
||||
else:
|
||||
raise TransferError('Recipient not found')
|
||||
|
|
|
|||
|
|
@ -17,13 +17,10 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||
from weboob.tools.captcha.virtkeyboard import VirtKeyboardError
|
||||
from weboob.capabilities.bank import Recipient, AccountNotFound, Transfer
|
||||
from weboob.tools.browser2.page import HTMLPage, LoggedPage
|
||||
from weboob.tools.browser import BrokenPageError
|
||||
from weboob.tools.browser2.page import HTMLPage, LoggedPage, ListElement, ItemElement, method
|
||||
from weboob.tools.browser2.filters import CleanText, CleanDecimal
|
||||
from .login import INGVirtKeyboard
|
||||
from logging import error
|
||||
|
||||
|
|
@ -148,45 +145,28 @@ class TransferConfirmPage(HTMLPage):
|
|||
if font.attrib.get('class') == "vide":
|
||||
realpasswd += password[i]
|
||||
i += 1
|
||||
confirmform = None
|
||||
divform = self.doc.xpath('//div[@id="transfer_panel"]')[0]
|
||||
for form in divform.xpath('./form'):
|
||||
try:
|
||||
if form.attrib['name'][0:4] == "j_id":
|
||||
confirmform = form
|
||||
break
|
||||
except:
|
||||
continue
|
||||
if confirmform is None:
|
||||
raise BrokenPageError('Unable to find confirm form')
|
||||
formname = confirmform.attrib['name']
|
||||
self.browser.logger.debug('We are looking for : ' + realpasswd)
|
||||
coordinates = vk.get_string_code(realpasswd)
|
||||
self.browser.logger.debug("Coordonates: " + coordinates)
|
||||
|
||||
form = self.get_form(name=formname)
|
||||
form = self.get_form(xpath='//div[@id="transfer_panel"]//form')
|
||||
for elem in form:
|
||||
if "_link_hidden_" in elem or "j_idcl" in elem:
|
||||
form.pop(elem)
|
||||
|
||||
coordinates = vk.get_string_code(realpasswd)
|
||||
self.browser.logger.debug("Coordonates: " + coordinates)
|
||||
|
||||
form['AJAXREQUEST'] = '_viewRoot'
|
||||
form['%s:mrgtransfer' % formname] = '%s:mrgtransfer' % formname
|
||||
form['%s:mrltransfer' % formname] = coordinates
|
||||
form['%s:mrgtransfer' % form.name] = '%s:mrgtransfer' % form.name
|
||||
form['%s:mrltransfer' % form.name] = coordinates
|
||||
form.submit()
|
||||
|
||||
def recap(self):
|
||||
if len(self.doc.xpath('//p[@class="alert alert-success"]')) == 0:
|
||||
raise BrokenPageError('Unable to find confirmation')
|
||||
div = self.doc.find(
|
||||
'//div[@class="encadre transfert-validation"]')
|
||||
transfer = Transfer(0)
|
||||
transfer.amount = Decimal(FrenchTransaction.clean_amount(
|
||||
div.xpath('.//label[@id="confirmtransferAmount"]')[0].text))
|
||||
transfer.origin = div.xpath(
|
||||
'.//span[@id="confirmfromAccount"]')[0].text
|
||||
transfer.recipient = div.xpath(
|
||||
'.//span[@id="confirmtoAccount"]')[0].text
|
||||
transfer.reason = unicode(
|
||||
div.xpath('.//span[@id="confirmtransferMotive"]')[0].text)
|
||||
return transfer
|
||||
@method
|
||||
class recap(ListElement):
|
||||
item_xpath = '//div[@class="encadre transfert-validation"]'
|
||||
|
||||
class item(ItemElement):
|
||||
klass = Transfer
|
||||
|
||||
obj_amount = CleanDecimal('.//label[@id="confirmtransferAmount"]')
|
||||
obj_origin = CleanText('.//span[@id="confirmfromAccount"]')
|
||||
obj_recipient = CleanText('.//span[@id="confirmtoAccount"]')
|
||||
obj_reason = CleanText('.//span[@id="confirmtransferMotive"]')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue