Reputation: 587
I need to automate filling multiple forms on a 3rd party site. The site is written in JavaScript; the protocol is HTTPS. I see 3 ways of accomplishing this.
Any comments, examples? E.g., what class should I try for #3?
I do NOT have any Web programming experience beyond basic HTML. I DO have extensive C++ (MFC), Java, and VB (Excel macros) experience.
Thanks!
UPDATE/Clarification. Currently, my colleague has to go to a site, enter his name/password, click a link -- copy-paste -- submit -- repeat over 9000 times. Instead, we want to be able to fill an Excel spreadsheet and click a single button that will fill out all forms on the site.
UPDATE #2. The problem with HTTPS is that "you cannot sniff the data which is the easiest way to replicate it" -- is that the consensus here? Then it would be difficult to form server requests correctly, even with cURL. I cannot test that much: this is pretty much live data, and correcting it later is difficult.
So, PhantomJS, Selenium... What about WatiN? And thanks again for your thoughts!
Upvotes: 1
Views: 8995
Reputation: 421
Try QA Agent (http://qaagent.com). It works in Chrome only (as of now) and you can easily develop this automated actions you mentioned by using javascript and jQuery.
Upvotes: 1
Reputation: 5459
I recommend a "browser-less" approach... if you use curl as g-makulik suggested, you could possibly batch/script the entire thing. If it doesn't require encryption, simple TCP sockets and basic HTTP headers would be easy to mimic (you could watch the traffic them do what it's doing). If it's SSL/TLS you can still look at the headers using a browser's developer tools, then use OpenSSL or Windows API to handle the encryption for you.
Upvotes: 1
Reputation: 286
You should check out selenium (http://docs.seleniumhq.org/). You can use Selenium IDE (I think it only works on Firefox) or use the WebDriver to automate the tests (with java or python).
With the IDE you can create your own macros using "clicks" and "key-presses". Please be aware of the Website's terms of service as @doron told you. With selenium, you can add timeouts to send the data politely to the server.
Upvotes: 0
Reputation:
1 or 3: You can use PhantomJS to accomplish this. It's not exactly sending mouse clicks or key presses; it is a headless WebKit browser controlled by JavaScript. The wiki has some useful examples of automating form input.
2: If you know the structure of the form, you can send the form data as a POST request via cURL
Example from cURL Tutorial:
<form method="POST" action="junk.cgi">
<input type=text name="birthyear">
<input type=submit name=press value=" OK ">
</form>
This would be the cURL command:
curl --data "birthyear=1905&press=%20OK%20" http://example.com
Upvotes: 2
Reputation: 28872
Doing this unilaterally (without the knowledge of the Site owner) may break when the Website is updated (since the site owner reserves the right make any changes they want.) In addition to this, you may be violating the Website's terms of service.
The best thing for you to do is to contact The Website owner and let them tell you how you should be automatically sending form data to the Website. If they provide you with an API you should have some degree of confidence that the API will be stable.
Upvotes: 2