LoginSignup
24
20

More than 5 years have passed since last update.

Seleniumでname属性をClickしてもSubmitされない

Last updated at Posted at 2014-06-06

問題

submitボタンをクリックしてフォームを送信したい。

Form.html
<input type="submit" name="post" value="投稿" />
FormTest.cs
driver.FindElement(By.Name("post")).Click();

ローカルでは動くが、
試験サーバでは毎回エラーが起こる画面が1つ発生。
なぜだ。

解決策

SendKeysにすると動くよ!(StackOverflow.com)

FormTest.cs
driver.FindElement(By.Name("post")).SendKeys(Keys.Enter);

または

FormTest.cs
driver.FindElement(By.Name("post")).SendKeys(Keys.Return);

原因(?)

バグっぽい。
再現シナリオがわからないからクローズされてる。
Issue 2864:Clicking with 2.12.0 using Firefox 5 sometimes works and sometimes does not

あとがき

私の環境は以下のとおり。
Selenium: 2.41.0.0(C#)
ローカル:Windows 7(x86) + Firefox 29.0.1
試験サーバ:Windows Server 2012 R2 + Firefox 29.0.1

HTML/CSSを並行で開発していて、
気づいたらClickでも送信されるようになっていた。
HTMLやCSSが原因?
気が向いたら調べてみます。

24
20
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
20