tags:

views:

385

answers:

1

I have a simple login form that has 2 text fields and a button. I can set the text of the username field just fine. When I set the password field however, the form automatically submits, and I get an error.

From IRB:

irb(main):008:0> ie.text_field(:name, "j_password").set("password")
WIN32OLERuntimeError: unknown property or method `value'
    HRESULT error code:0x80070005
      Access is denied.
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3431:in `method_missing'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3431:in `doKeyPress'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3427:in `each'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3427:in `doKeyPress'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3393:in `set'
        from (irb):8
irb(main):009:0> ie.text_fields.each {|x| puts x }
type:         text
id:
name:         j_username
value:
disabled:     false
length:       20
read only:    false
type:         password
id:
name:         j_password
value:
disabled:     false
length:       20
read only:    false

Any ideas why the error, or why the form is being submitted?

Note: I can set the fields just fine without the form being submitted using perl, vbscript, python, autoit, etc.

+1  A: 

I could tell you more if you posted relevant HTML or link (if page is public), but my guess is that entering password fires JavaScript event that submits the form. Access is denied. could mean that there is a frame, and IE does not allow access to it (http://wiki.openqa.org/display/WTR/Frames).

Maybe this would help:

ie.text_field(:name, "j_password").value=("password")
Željko Filipin
Works great!There is no javascript to submit the form on entering the password, but there some that fires on a specific letter combination that I was un-aware of. The actual string that I was passing just happened to contain it. Thanks again.
CalvinTreg
I am glad I could help. :)
Željko Filipin