试图弄清楚如何使用 textarea 选择表单上的字段并指定类和 ID。不幸的是,我无法控制生成的 HTML,因为它是供应商产品。
示例 HTML:
<textarea class="text sr " id="arid_WIN_0_636875000" style="left: 402px; top: 0px; width: 261px; height: 21px;" rows="1" cols="20" wrap="off" arautoctt="400" arautocak="0" maxlen="255"></textarea>
我需要同时使用 ID 和类,因为 ID 用于多个点以及类,但是,我发现两者的组合是唯一的。
我试过做:
z = textarea(:class => "text sr ", :id => "arid_WIN_0_636875000")
这回来了:
=> #<Watir::TextArea:0x272de17c located=false sel
>"arid_WIN_0_636875000", :tag_name=>"textarea"}>
尝试设置它并返回:
Watir::Exception::UnknownObjectException: unable to locate element, using {:class=>"text sr ", :id=>"arid_WIN_0_636875000", :tag_name=>"textarea"}
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.7.0/lib/watir-webdriver/elements/element.rb:507:in `assert_exists'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.7.0/lib/watir-webdriver/user_editable.rb:32:in `clear'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.7.0/lib/watir-webdriver/user_editable.rb:11:in `set'
from (irb):21:in `block in irb_binding'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/common/target_locator.rb:50:in `window'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.7.0/lib/watir-webdriver/window.rb:193:in `use'
from (irb):20
from C:/Ruby21/bin/irb:11:in `<main>'
这是弹出窗口的 HTML:
<div class="DIVPopup shadow " id="popup_0" style="left: 495px; top: 161.5px; width: 930px; height: 673px; overflow: hidden; visibility: inherit; z-index: 100004;" arwindowid="0"><table class="DIVPopup ResizablePopup" id="DivTable" cellspacing="0" cellpadding="0"><tbody><tr class="DIVPopupTitleBar DIVDraggable"><td class="topleft"> </td><td align="left" class="center" id="title_0" nowrap=""><div class="title">Name of form is here </div><button title="Close" class="Close right" id="ardivpcl" onclick="var target=FindClickedPopup('0', event); if(target){ target.OnCancel();target.stopBubbling(event);return false;}" type="button"></button></td><td class="topright"> </td></tr><tr><td class="DIVPopupBodyNoBorder DIVPopupBodyBorder" colspan="3"><iframe id="1433419427651P" src="/arsys/forms/vmpit-ermdy006/NameOfFormIsHere/Administrator/?cacheid=fa90df9&format=html" frameborder="0" style="width: 100%; height: 652px;"></iframe></td></tr></tbody></table><b class="rndfooter" style="background-color: rgb(255, 255, 255);"><b class="rnd1" style="background-color: rgb(255, 255, 255);"></b><b class="rnd2" style="background-color: rgb(255, 255, 255);"></b><b class="rnd3"></b></b><div class="ResizeHandle right" id="handle_0"></div></div>