Problem I'm Trying To Solve
On a non-secure (http) page, when you click a "Log in" link we load a
secure login form inside an iframe. I'm trying to wait for it to load
before filling it out and submitting. Simple enough, right?

Approach
1. Wait for the iframe to exist
2. Wait for the password field to exist
3. Wait for the password field to become visible
4+ Fill out the form and submit

Code I Want To Use (Works some of the time, randomly)
…
33  Wait.until { @browser.frame(:index, 1).exists? } #Always works
34  Wait.until { @browser.frame(:index, 1).text_field(:id,
"password").exists? } #Always works
35  Wait.until { @browser.frame(:index, 1).text_field(:id,
"password").visible? } #Failure line, when it fails
… # Then fill it out etc, which is working fine

Unhelpful Error I Get When It Fails
wrong number of arguments (2 for 1) (ArgumentError)
./features/step_definitions/secure_login_steps.rb:35
./features/step_definitions/secure_login_steps.rb:35:in `/^I log in
using the overlay$/'
features/secure_login.feature:9:in `When I log in using the overlay'

What I Think Is Happening
It seems like "@browser.frame(:index, 1)" and "@browser.frame(:index,
1).locate" aren't always returning the frame, but are rather sometimes
returning the parent document.

If this is the case, it's possible that in line (34) above, the
"@browser.frame(:index, 1)" is returning the parent document, and it's
thus checking that the wrong "password" text exists (which is already
on the parent document, so it returns true immediately), and then in
line (35) "@browser.frame(:index, 1)" returns the iframe, which hasn't
fully loaded yet, so it's trying to check ".visible?" on a nonexistent
object, and bombing out.

My two questions are:
1. Is ".frame()" known to be inconsistent like this? Am I doing it
wrong?
2. Is there a better, simpler way to achieve my overall goal than what
I'm doing?

Thanks,
Steve

Env:
Cuke 1.0.0
Firewatir 1.8.0
watir-webdriver 0.2.0
Ruby 1.8.7
Firefox 3.6.19
JSSh 0.9

On Aug 5, 2:33 pm, Stephen Lee <[email protected]> wrote:
> heh, sorry - hit <tab> instead of <caps lock> on accident, then enter,
> and prematurely submitted this. More to come in a sec...
>
> On Aug 5, 2:22 pm, Stephen Lee <[email protected]> wrote:
>
>
>
>
>
>
>
> > I'm getting inconsistent behavior when trying to work with a frame
> > using firewatir
>
> > PROBLEM I'M TRYING TO SOLVE
>
> > Env:
> > Cuke 1.0.0
> > Firewatir 1.8.0
> > watir-webdriver 0.2.0
> > Ruby 1.8.7
> > Firefox 3.6.19
> > JSSh 0.9

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

Reply via email to