how to address custom id textboxes?

41 views
Skip to first unread message

Benja Mindsche

unread,
Mar 12, 2016, 12:00:44 PM3/12/16
to splinter-users
I am trying to write a script to automatically login to my bank account and download account movements as xml. There is no API to do so, so I was considering splinter to handle this for me.

However, the user name and password box do not have IDs I can provide. Their IDs change each time one reloads the login page. 
Is there a way to still log me in? 

I am still learning Python and am not sure how to solve this problem. Help would be greatly appreciated.

Thanks =)

Gabriel Lima de Oliveira

unread,
Mar 14, 2016, 5:51:40 PM3/14/16
to splinte...@googlegroups.com
If your problem is to locate the input elements, please share a schematic of what the page looks like (HTML).


 Att,
Gabriel L. Oliveira

--
You received this message because you are subscribed to the Google Groups "splinter-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to splinter-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benja Mindsche

unread,
Mar 16, 2016, 8:58:45 AM3/16/16
to splinter-users
Here's a link to that page.
I need to identify those boxes labeled "

I have tried searching the html source code for those two ID values, writing them in a variable, then using that variable in splinter.
browser.fill(loginId, myLog)

When testing this, it seems to find the correct IDs (though I am using terrible algorithm to find them). When I print those IDs and compare them to the current html source code, they match. However, according to terminal output, they are incorrect. 

Benja Mindsche

unread,
Mar 16, 2016, 12:07:26 PM3/16/16
to splinter-users
Ok, I have cleaned up my algorithm.

from splinter import Browser
import re
browser = Browser('zope.testbrowser')

url = "https://banking.ksk-ratzeburg.de/portal/portal/Starten"
myLog = "my Login"
myPw = "my Password"

browser.visit(url)
content = browser.html

m = re.findall(r'<input id=\'\w{16}\'', content)
loginId = (m[0][11:-1])
myLog = (m[1][11:-1])
browser.fill(loginId, myLog)

This should find the correct IDs for login and password box. However, I get an error like 
ElementDoesNotExist: no elements could be found with name "uaAtlRKQseRHBBpC"

 AFAIK, each ID should be 16 characters long. So I am not sure why this does not work.

Hugo Lopes Tavares

unread,
Mar 16, 2016, 12:35:21 PM3/16/16
to splinte...@googlegroups.com
The `fill` method expects a name, not an id. Look at the source code: https://github.com/cobrateam/splinter/blob/261ef6d998bc31d4d726aa370d35803f961ede73/splinter/driver/zopetestbrowser.py#L193-L194

If you want to use ids, you can find the element and then call its `fill` method[1], something like:

    browser.find_by_id(loginId).fill(myLog)




--

Benja Mindsche

unread,
Mar 16, 2016, 12:48:01 PM3/16/16
to splinter-users
Thank you.

According to the html source code, id and name are identical. There are actually label, id, name and data-cip-id. They all have the same value, a 16 character string.

Gabriel Lima de Oliveira

unread,
Mar 16, 2016, 6:35:29 PM3/16/16
to splinte...@googlegroups.com
For that, you can use

inputs = browser.find_by_css('loginfeld')
login_input = inputs[0]
password_input = inputs[1]

or improve this search by using xpath and looking for css ".loginfield" and "type=text" (or type=password) for either case.

For more information about finding elements:
http://splinter.readthedocs.org/en/latest/finding.html




 Att,
Gabriel L. Oliveira
Reply all
Reply to author
Forward
0 new messages