0

以下は私のコードです

<TR ID="oldContent"><TD><input type="text" name="code" id="oldContent"></TD></TR>
<TR ID="oldContent"><TD><input type="text" name="code"  id="oldContent"></TD></TR>

ここでは、テキスト ボックスの名前、ID、およびタイプが同じではありません。これらのテキスト ボックスにデータを入力することはできません。

私は以下を試しました

selenium.type("xpath=//input[1][@name='code']",87767);
selenium.type("xpath=//input[2][@name='code']",67458);


selenium.type("xpath=//input[1][@name='code' and @type='text']",87767);
selenium.type("xpath=//input[2][@name='code' and @type='text']",67458);

selenium.type("xpath=//input[@name='code' and @type='text'][1]",87767);
selenium.type("xpath=//input[@name='code' and @type='text'][2]",67458);

誰もそれを見つけるためにxpathで私を助けることができますか?

4

3 に答える 3

0

x-path の代わりに dom を試してください。はるかに簡単です。

于 2012-12-27T11:26:38.440 に答える
0

あなたのHTMLがそのようなものであると仮定します:

<table id="someId">
  <tr id="oldContent">
    <td>
      <input type="text" name="code" id="oldContent" />
    </td>
  </tr>
  <tr id="oldContent">
    <tr>
      <input type="text" name="code"  id="oldContent" />
    </td>
  </tr>
</table>

以下を使用します。

selenium.type("css=table#someId > tr#oldContent:nth-child('1') input[type='text']",87767);
selenium.type("css=table#someId > tr#oldContent:nth-child('2') input[type='text']",67458);
于 2012-12-19T06:27:56.583 に答える
0

この xpath を試してください: //tr[@id='oldContent'][1]//input[@name='code']

于 2012-12-20T19:50:30.773 に答える