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.

4

1 回答 1

1

如果您发布了相关的 HTML 或链接(如果页面是公开的),我可以告诉您更多信息,但我的猜测是输入密码会触发提交表单的 JavaScript 事件。Access is denied.可能意味着有一个框架,而 IE 不允许访问它(http://wiki.openqa.org/display/WTR/Frames)。

也许这会有所帮助:

ie.text_field(:name, "j_password").value=("password")
于 2009-11-05T09:55:10.487 回答