私は、この要素を識別することができますどのように

樹液:

私は、一意のID、クラスまたは属性を持っていない「テキスト応答で質問を」この要素を識別します。

私はこれを試してみました:

@FindBy(css = "body")

缶誰もがこれを見つけるために私を助けてください?

ここではHTMLは次のようになります。

<tr valign="top" xpath="1">
   <td width="80%">
      <div id="div-4fd242f670a4bc4e0170beb543d72c66" class="wordwrap" style="padding-left:20px;padding-top:3px;">
         <label for="name" class="portlet-form-field-label">
         2.
         Question With Text Response<span style="color:red;">*</span>
         </label>
         <br>
         <textarea id="4fd242f670a4bc4e0170beb543d72c66" name="answers[4fd242f670a4bc4e0170beb543d72c66]" class="portlet-form-input-field answers[4fd242f670a4bc4e0170beb543d72c66]  comment" style="width:90%;" onkeydown="return imposeMaxLength(event, this, 3999);" onblur="return imposeMaxLength(event, this, 3999);" rows="7"></textarea>    				
      </div>
   </td>
</tr>

Nrendrari:

あなたのHTML構造ごとなどlabeltextarea、ラベルのテキストに基づいてテキストエリアを特定するので、タグを兄弟しています

XPathの下に使用します。

@FindBy(xpath = "//label[contains(.,'Question With Text Response')]/following::textarea")

説明:

//label[contains(.,'Question With Text Response')] - 「テキスト応答と質問」のテキストが含まれている検索ラベル

/following::textareaまたは/following-sibling::textarea-テキストを見つけラベルに続くです

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=279871&siteId=1