I'm trying to prefill webforms in iframes using Requests. If that can't be done, does anyone have a script I can use that works with webbrowser? I like that it calls the default web browser in just about any system, which is great for my Android applications.

I've tried using splinter, a wrapper to selenium, but it only opens the browser--firefox only--for a second, fills out the iframe, and then automatically closes. Below is my splinter code.

with Browser() as browser:
    browser.visit(url)
    r = browser.find_by_id('inpage_to_email').fill('ben@me.com')

Any help would be greatly appreciated!

Recommended Answers

All 2 Replies

but it only opens the browser--firefox only--for a second, fills out the iframe, and then automatically closes.

I believe this is because the context manager in this case destroys the browser instance the moment it goes out of scope (i.e. as soon as you exit the with block). You can test this out by removing the with block and using your code like:

browser = Browser()
browser.visit(url)
# other stuff

Yeah, I figured it out eventually. Thank you for taking the time to answer the question, btw. I should've come back to answer once I figured it out, so I apologize for that.
So splinter works, but the problem is that it won't work on my android device. Back to the drawing board.
Again, thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.