Forum: Ruby Not able to enter value in text box inside the iframe

Posted by Nitin Nazare (nitinm84)
on 2013-02-05 11:02
Hello,

My team is trying to automate web application using Watir. We are able
to automate the application flow successfully, but at the last point we
have process where we have to click on purchase button, an iframe gets
opened. We have to provide data values in the text box. We are not able
to automate this portion (iframe). Can anybody please help us to
automate iframe portion.

We have tried with the nested element to enter value, but watir is
not able to identify the text box.

e.g.

ie.div(:id, "div_b").iframe(:id, "up_payframe").text_field(:name,
"cc").set "12345"

its not working.

below is the DOM structure taken from firebug

<tr>
<td></td>
<td align="left">
<div class="cc_forminput"><input id="cc" class="text-box" type="text"
onfocus="resetInputError(this)" maxlength="20" name="cc"
value=""></input></div>
</td>
</tr>
Posted by Love U Ruby (my-ruby)
on 2013-02-05 11:15
Nitin Nazare wrote in post #1095290:
> Hello,
>
> My team is trying to automate web application using Watir. We are able
> to automate the application flow successfully, but at the last point we
> have process where we have to click on purchase button, an iframe gets
> opened. We have to provide data values in the text box. We are not able
> to automate this portion (iframe). Can anybody please help us to

You can use "xpath"
Posted by Joel Pearson (virtuoso)
on 2013-02-06 01:11
"Not working" is vague. Do you get an error message? does the object 
show as present? visible?

Have you tried using IRB and an active watir session to try various 
selectors and see what happens?

Sometimes being more vague helps, like ie.text_field(:name,"cc")

Also, try listing all frames and getting their names /ids

ie.frame(:index => 0).name

Interestingly the first result I noticed when looking up Watir and 
iFrames was a comment that watir-webdriver works better with them. 
Perhaps this is a possibility you could look into.
http://watirtips.blogspot.co.uk/2011/05/iframes.html
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.