'Script to automatically log in to webpage and click button

I have a time clock system that employees login to via browser and punch for time but I find that the process takes our less tech savvy employees 4-5 minutes. Is there a way to make a script that would auto-login for them, load the punch page, and then select the clock function via menu and then click the 'punch' button? Ideally I'd like to make two shortcuts on the desktop linking to these scripts: one for clocking in and one for clocking out. The button and menu both have IDs so I know it is possible to assign those values via javascript, but I'm unsure of how to do the auto-login / page redirection.



Solution 1:[1]

I see several ways you could go with this.

  • Coding scripts using WebDriver. WebDriver is a browser driver library and should be able to generally interact with most elements, so it could likely do what you're looking for. WebDriver works in a variety of programming languages which gives you flexibility. Here's the getting started guide for Java.
  • Use a macro recorder like AutoHotKey. Later versions come complete with COM support and you could hook up to Internet Explorer. More details are here. If you don't know AutoHotKey, you'll likely want to go through some of the initial tutorials before digging through that post though.
  • The third way would be to look for an API or web service or even a tool like curl (a command line tool to fetch URLs). Depending on how your time card application is coded, you might be able to create a batch script that never actually renders the page but just calls the URL in succession. This is likely to be the fastest solution for the users but may prove difficult if there's a lot of asynchronous script calls or PUT http requests in your app. A curl tutorial is available here.

Solution 2:[2]

Another solution: Sikuli (free, open source, Linux/Mac OS X/Windows). It allows you to write Python script that clicks on the screen based on the screenshot you provide.

enter image description here

You might also be interested in Selenium IDE:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andy Tinkham
Solution 2