###webbrowserクラスでブラウスしたい
自動ブラウジングするためにinputタグにテキストを入れたりボタンを押したりしたいです。
しかし、submitボタンが押せずに困っています。
###発生している問題
<form action="hoge"...> <input type="submit"...> </form>
のsubmitボタンが押せません.htmlelementでformを取得してsubmitしても、inputを取得してclickしてもエラーメッセージはなく、また応答もありません。ウィンドウに表示して手動で動かすと動くのでwebbrowserクラスやVSが固まっているわけでもないようです。
例えばgoogleの検索ページ(https://www.google.co.jp/)だと以下のようなコードになります。
よろしくお願いします。
html
1<form class="tsf" action="/search" style="overflow:visible" id="tsf" method="GET" name="f" onsubmit="return q.value!=''" role="search"> 2 <!--略--> 3 <center> 4 <input value="Google 検索" aria-label="Google 検索" name="btnK" type="submit" jsaction="sf.chk"> 5 <input value="I'm Feeling Lucky" aria-label="I'm Feeling Lucky" name="btnI" type="submit" jsaction="sf.lck"> 6 </center> 7 <!--略--> 8</form>
C#
1bool input_submit() 2{ 3 HtmlElementCollection all = web_b.Document.GetElementsByTagName("form"); 4 foreach (HtmlElement tag in all) 5 { 6 try 7 { 8 if (tag.InnerHtml.Contains("google 検索")) 9 { 10 tag.InvokeMember("submit"); 11 wait(); //completedまで待機 12 return true; 13 } 14 } 15 catch (Exception ex) 16 { 17 textbox.Text += ex.ToString(); 18 } 19 } 20 return false; 21}
###試したこと
上記したコードは"form"と"submit"でしたが、"form"と"input"、"click"と"submit"の組み合わせはすべて試しました。また、あらかた調べましたがわからなかったです。
###補足情報(言語/FW/ツール等のバージョンなど)
- VS Express 2013 for Desktop update 5
- Visual C# 2013
- .NET Framework Version 4.7
あなたの回答
tips
プレビュー