2017-08-11 4 views
-1

以下はコードです。誰かがインデックスを使わずに、3つのテキストボックスを個別に識別できるように助けてくれますか?インデックスを使用せずに第1、第2、第3のテキストボックスを特定するにはどうすればいいですか?(ex [1]) - xpath、selenium

<html> 
    <head> 
     <title>test</title> 
     <script></script> 
    </head> 
    <body> 
     name: 
     <input type="text"/> 
     <br/> 
     name: 
     <input type="text"/> 
     <br/> 
     name: 
     <input type="text"/> 
     <div>testdiv</div> 
    </body> 
</html> 
+0

あなたの3つの要素はすべて同じですので、 '// input [last()]'のような関数を使うことができるなら間接的に '// input [1]'のようなインデックスを使うことができます - // input [last() - 1] ' - ' position() ' - ' // input [position()= 1] 'などを使って2番目に最後に入力されたタグを探します。 – NarendraR

+2

あなたのビジネス要件は何ですか?なぜあなたはインデックスを避けたいのですか? – DebanjanB

+0

問題の解決方法を表示する – Andersson

答えて

0

あなたは各input一致する表現の下に試すことができます:最初の1のために

//input[not(preceding-sibling::input)] 

秒の場合:

//input[preceding-sibling::input and following-sibling::input] 

第三の場合:

を210
関連する問題