开发者

How to simulate button click programatically

Hai every one, I am developing an application where users can subscribe or unsubscribe to a group of mailing list using .net.I am using webclient class as below

NameValueCollection formData = new NameValueCollection();
formData.Add("email", txt_emailid.Text);
WebClient webClient = new WebClient();
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string response = Encoding.UTF8.GetString(responseBytes);

where the res开发者_开发百科ponse contains one more button(unsubscribe).what i have to do is to simulate the (unsubscribe)button click programmaticaly from my .net application.Is there any way to do this?

Thanks& Regards Chaithu


It sounds like your trying to do a integration test on a web page or almost imply the same situation as a test.

Have you looked at WATIN (http://watin.sourceforge.net/) for clicking the button as this will allow you to find the button and click it easily. This will create an instance of a browser on the system running the code and do the actions associated with it (from memory I think the instance can be opened in a minimised state). You should also check out Selenium as well.

Darin is correct in what he is saying if you want to do it via a WebClient class. Just remember to make sure you pass the button's id in the form data otherwise the server will not know which button has been clicked.


It depends on what this button is doing. If it sends an HTTP request you could once again use WebClient to simulate it by sending all the necessary parameters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜