如何使用 watir 访问 <body> 标签

How to access the <body> tags using watir

我正在尝试通过 watir 撰写电子邮件。所以当我试图访问它时,它有 标签。谁能建议如何访问它?

我的系统配置

IE-8Inter code here
Windows-7

我做了以下

require 'rubygems'
require 'watir'
@ie.text_field(:id,':13r').set 'sample'



HTML CODE






<iframe tabIndex="1" class="Am Al editable" id=":13s" src="" frameBorder="0"
              style="padding-bottom: 0px; background-color: white; padding-left: 
           0px; padding-right: 0px; height: 248px; overflow: visible; padding-top:  
      0px;" allowTransparency="" closure_lm_162187="null" target="[object]" 
    originalTarget="undefined">
    <html>
    <head>
    <title></title>
    <style>CSSSTYLEsheet</style>
    </head> 
             <body class="editable LW-avf" id=":158" role="textbox" 
            contentEditable="true" hideFocus="hidefocus" closure_lm_478727="[object Object]" g_editable="true"/>
</html>

我正在尝试将其作为文本框访问,因为 "role" 属性的值为 "textbox"。

我收到错误 :274:在assert_not_readonly' from C:/svn/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/input_elem ents.rb:368:in设置'

上面有 iframe 元素 try as

@ie.iframe(:id,':13r').body(:id,':13r').set 'sample'

watir-webdriver 中有一个 body method in watir-classic, and there's a body 方法。

根据 watir-classic 文档,您可以通过多种方式定位元素,包括 id 属性或任意 HTML 属性:

browser.body(:id => "htmlid")
browser.body(:foo => "value-of-foo-attribute)