2017-03-12 2 views
0

私はHTMLでこのコードを持っている:ウェブドライバC#のxpth CSSの要素の識別

<br> 
input name="commit" value="Apply" style="" type="submit" 
<br> 

をそして、それは私が次のエラーメッセージが表示されます、私は

heredriver.FindElement(By.XPath("//input[@name='commit'][4]")).Click(); 
or 
driver.FindElement(By.CssSelector("#new_reduction > input[name="commit"]")).Click(); 

にウェブ・ドライバ・コードで書いたものです:

そのような要素:要素が見つかりません:{ "方法": "のXPath"、 "セレクタ": "//入力【名@ = 'コミット'] [4]"}

コメントから

追加html

<form class="new_reduction" id="new_reduction" action="/admin/reductions" accept-charset="UTF-8" method="post"> 
    <input name="utf8" type="hidden" value="✓"> 
    <input type="hidden" name="authenticity_token" value="mZHoKI82s1fk7w2FCsqbNiGM9kJyE45dzwV3w2cuFzniZe6lDDum9‌​LDNxAsIokpxH90b/cFxq‌​Cil5EMvuvBwA=="> 
     Cou‌​pon Code: 
    <input value="3167050" type="hidden" name="reduction[order_id]" id="reduction_order_id"> 
    <input value="81069" type="hidden" name="reduction[web_user_id]" id="reduction_web_user_id"> 
    <input type="text" name="code" id="code"> 
    <input type="submit" name="commit" value="Apply"> 
</form> 
+0

のないエラーとは何ですか? – Guy

+0

追加情報:該当しない要素:{"method": "xpath"、 "selector": "// input [@ name = 'commit'] [4]」 –

+1

あなたの要素は' iframe '? – NarendraR

答えて

0

てみ指数

driver.FindElement(By.XPath("//input[@name='commit']")).Click(); 
// or 
driver.FindElement(By.Name("commit")).Click(); 
+0

私はそれがうまくいきませんでした –

+0

ポストフルHTML – Dazed

+0

クーポンコード: <入力値= "3167050" タイプ

関連する問題