пятница, 30 апреля 2010 г.

Submitting a form while automating IE using vb.net

http://blog.vivekjishtu.com/2006/02/submitting-form-while-automating-ie.html
If you are planning to automate IE using VB.net and you have previously used WebBrowser control as an ActiveX control you could very well be surprised. You just might feel restricted using the System.Windows.Forms.WebBrowser control compared to the ActiveX Control. The first and the biggest problem you might face is that the System.Windows.Forms.WebBrowser is very strongly type checked, which makes things like in the example below impossible to achive.
AxWebBrowser1.Document.forms(0).q.value = "foxpose"
AxWebBrowser1.Document.Forms(0).submit()
Using the newer managed control you need to use the example given below.
WebBrowser1.Document.All("q").SetAttribute("value", "foxpose")
WebBrowser1.Document.Forms(0).InvokeMember("Submit")
This took quite a lot of my time yesterday. I hope this code somehow helps someone out when they are programming the new managed control in .NET 2.0 Incase you want a more detailed example just leave a comment and I will modify the post to include a more detailed example.

Комментариев нет:

Отправить комментарий