Recently, I come across the need for simulate the user browser web behavior. I need to simulate the user behavior by going to particular URL, filling the form and submit the request and even download the file.
There defiantly will be more then one way can do it. I intend to focus on the solution which can use the language I familiar with: Perl and PowerShell.
Perl: LWP::UserAgent seems to be the way to go. This seems to be able to send the HTTP POST request. During my very short period time of testing. It does not work for me. Probably is because I do not have the proxy server set up. ( My environment has some proxy server/firewall restriction).
Also, since I may need to implement the solution on the windows. I spend more time on digging the solution for PowerShell.
DotNet WebClient class seems can achieve similar way like LWP. I have not spend much time on it yet. I found the “InternetExplorer.Application” is very interesting and easy to use.
Here is some testing sample code
I use the Firefox plugin firebug to find the proper HTML tag.
The current issue I am having is by using this approach to download the file. When I try to download the text file, it will be blocked by the information bar. Since in the real production environment, I do not have permission to disable the information bar via HKLM register key nor adding the website to the trust zone in IE. I have stuck on this for now.
One of limitation using this is that you have to have the Internet explorer install on the same host where you run the PowerShell. Since you are running the PowerShell already. I wont think it is much of big deal. However, I do concern about the Internet Explorer stability. I am not sure what if the IE has a lot of plugin or not stable, how would it impact the PowerShell Script.
Web UI Automation with Windows PowerShell http://msdn.microsoft.com/en-us/magazine/cc337896.aspx