Trying to figure out how to select a field on a form using textarea with specifying the class and the ID. Unfortunately, I don't have control over the HTML that is generated as it is a vendor product.
Sample 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>
I need to use both the ID and the class because the ID is used in multiple spots as well as the class, however, I have found the combination of the two is unique.
I've tried doing:
z = textarea(:class => "text sr ", :id => "arid_WIN_0_636875000")
This came back with:
=> #<Watir::TextArea:0x272de17c located=false sel
>"arid_WIN_0_636875000", :tag_name=>"textarea"}>
Tried setting it and came back with:
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>'
This is what the HTML is for the popup:
<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>
Given the HTML for the popup, I would guess that it is just a div element within the original page rather than its own browser window. Accessing the popup should be with:
browser.div(:id => "popup_0")
That said, I do not see the textarea in it, which means it is likely in the iframe element. Iframes have to explicitly told to Watir, which means to find the textarea you need:
browser.div(:id => "popup_0").iframe.textarea(:class => "text sr ", :id => "arid_WIN_0_636875000")