如何使用watir访问标签

时间:2015-03-01 16:59:37

标签: ruby watir watir-webdriver

我正在尝试通过watir撰写电子邮件。因此,当我尝试访问它时,它具有< body>标签。任何人都可以建议如何访问它?

我的系统配置

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>

我试图将其作为文本框访问为&#34;角色&#34; attribute的值为&#34; textbox&#34;。

我收到了错误 :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设置&#39;

I am Trying to compose the mail through Watir,the element that I tried access is body can anyone tell me how to access it

2 个答案:

答案 0 :(得分:2)

上面有iframe元素试试

@ ie.iframe(:id,&#39;:13r&#39;)。body(:id,&#39;:13r&#39;)。set&#39; sample&#39;

答案 1 :(得分:0)

watir-classic中有body方法,watir-webdriver中有body方法。

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

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