# Mechanize iframes

**URL:** <https://www.ruby-forum.com/t/mechanize-iframes/101775>\
**Category:** Ruby\
**Created:** [August 7, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/mechanize-iframes/101775 "2006-08-07T22:22:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 7, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/mechanize-iframes/101775/1 "2006-08-07T22:22:16Z")

</div>

Hi,  
could anyone give me an idea how can I get any element inside iframe  
using mechanize?

i get  
irb(main):026:0\> page.iframes  
=\> [‘view\_frame’ → /something?some\_id=1234]  
how can I fill form, click on links inside this iframe?

I’ve try several ways including something perl like:

> **[WWW::Mechanize::FAQ - Frequently Asked Questions about WWW::Mechanize -...](https://metacpan.org/dist/WWW-Mechanize/view/lib/WWW/Mechanize/FAQ.pod)**
>
> Frequently Asked Questions about WWW::Mechanize

irb(main):028:0\> page.links(:tag, “view\_frame”)  
ArgumentError: wrong number of arguments (2 for 1)

I will appreciate any help

regards

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 8, 2006, 3:40am UTC](https://www.ruby-forum.com/t/mechanize-iframes/101775/2 "2006-08-08T03:40:41Z")

</div>

Hey,

On Tue, Aug 08, 2006 at 05:20:11AM +0900, removed\_email\_address@domain.invalid wrote:

> Hi,  
> could anyone give me an idea how can I get any element inside iframe  
> using mechanize?
> 
> i get  
> irb(main):026:0\> page.iframes  
> =\> [‘view\_frame’ -\> /something?some\_id=1234]  
> how can I fill form, click on links inside this iframe?

Ruby Mechanize treats frames like links. You’ll need to “click” the  
iframe before you can manipulate html loaded in the iframe. Try  
something like the following:

iframe\_page = agent.click page.iframes.first  
iframe\_page.forms.each do |form|  
p form  
end

Also see the RDoc for WWW::Mechanize::Frame. Hope that helps.

–Aaron
