私は、ページオブジェクト内のtext_fieldを使用しての中の最初の<input>
フィールドを識別したい次のHTMLのWebページで作業しています。XPathを使用して、入力フィールドをIDなしで検索する方法
<div id="131:"> Please enter your name:
<span class="autocompspan " style="position:static;">
<input style="position: static;" class="autocompinput yui-ac-input" id="132:" name="132:"
onfocus="juic.fire("132:","_focus",event);"
onchange="juic.fire("132:","_despatchChange",event);"
onblur="juic.fire("132:","_blur",event);" size="60"
onkeydown="juic.fire("132:","_onkeydown",event);"
onkeyup="juic.fire("132:","_onkeyup",event);" aria-disabled="false" value=""
role="combobox" aria-autocomplete="list" aria-owns="132:_divList"
aria-activedescendant="132:_divAD" findtype="proxy" delimchar="" hideusername="false"
fetchusername="false" autocomplete="off" type="text">
<input value="" id="132:_hidden" name="132:_hidden" type="hidden">
</span>
</div>
フィールドを識別するために:id => '132:'
を使用すると正常に動作します。私。 text_field(:target_user_name, :id => '132:')
が動作します。
問題は、このHTMLはいつもid
が一貫要素を識別するために依拠することはできません使用して<input>
フィールドid
同じ値を生成していない基本的なアプリ(SAP)によって生成されていることです。 したがって、上記のHTMLでは、この<input>
フィールドを確実に見つける方法について他にどのような方法がありますか。
私は以下のことを試しましたが、いずれも動作しません。彼らのほとんどは、要素の位置を待っている時間があります。
text_field(:target_user_name, :xpath => "//*[@class='autocompinput yui-ac-input' and @role = 'combobox']")
text_field(:target_user_name, :xpath => "//*[@class='autocompinput' and @role = 'combobox']")
text_field(:target_user_name, :xpath => "//span/input[@class='autocompinput yui-ac-input' and @role = 'combobox']")
text_field(:target_user_name, :xpath => "//input[@class='autocompinput yui-ac-input' and @role = 'combobox']")
text_field(:target_user_name, :class => 'autocompinput yui-ac-input')
ユーザーとして、 ?このテキストフィールドが何であるかをユーザーに知らせるための、ユーザーが見ることのできるテキストがある可能性があります。私はそのテキストと、このフィールドとの関係を使って識別を行います。 –
入力を囲むスパンを囲むフィールドラベルを持つdivがあります。 – BobL
上記のコメントを再入力してください - XPATHのように見えて、その場合は入力フィールドが見つかりますか? XPATHSは、入力フィールドの属性が正しく機能すると思っていたでしょうか。 – BobL