I am trying to fill in fields on a login form with splinter. When I examine the rendered page, I see that the username input box has both a tag and a name of "u". How can I fill in this field from splinter? I tried the following:
from splinter import Browser
url = "http://www.weiyun.com/disk/login.html"
browser = Browser('firefox')
browser.visit(url)
browser.fill("u", "[email protected]")
print "done"
But there is no such field according to the error returned:
ElementDoesNotExist: no elements could be found with name "u"
How does one fill in the input fields on pages like this using splinter?
The problem is that your form is inside an iframe
, use get_iframe()
to interact with it:
with browser.get_iframe('_qq_login_frame') as iframe:
iframe.fill("u", "[email protected]")
Demo to show the difference:
>>> browser = Browser('firefox')
>>> browser.visit(url)
>>> browser.find_by_name('u')
[]
>>> with browser.get_iframe('_qq_login_frame') as iframe:
... iframe.find_by_name('u')
...
[<splinter.driver.webdriver.firefox.WebDriverElement object at 0x102465590>]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With