caesar318 caesar318 - 2 months ago 28
Python Question

python- using splinter to open and login webpage failed, help!!

https://idmsa.apple.com/IDMSWebAuth/signin?appIdKey=990d5c9e38720f4e832a8009a0fe4cad7dd151f99111dbea0df5e2934f267ec8&language=HK-en&segment=R409&grpcode=g001&view=6&rv=1&paramcode=h006&path=%2Fgeniusbar%2FR409%2Fen_HK&path2=%2Fgeniusbar%2FR409%2Fen_HK

I want to auto login this website,but it's doesn't work not matter browser.fill or

find_by_name
or
find_by_id


below was the information of input:

<input type="email" class="si-text-field" id="appleId" can-field="accountName" autocomplete="off" autocorrect="off" autocapitalize="off" aria-required="true" required="required" aria-labelledby="appleIdFieldLabel" spellcheck="false" autofocus="" placeholder="Apple ID">
<input type="password" id="pwd" aria-required="true" required="required" can-field="password" autocomplete="off" class="si-password si-text-field " placeholder="Password">


but when I use code below,it doesn't work, I don't know any special of the login form,

browser.fill("appleId","***")
browser.fill("pwd","***")

splinter.exceptions.ElementDoesNotExist: no elements could be found with name "appleId"

Answer

The form is inside an iframe, switch to it before filling the login and password:

with browser.get_iframe('aid-auth-widget-iFrame') as iframe:
    browser.find_by_id("appleId").type("your login") 
    browser.find_by_id("pwd").type("your password")