Script to automatically log in to webpage and click button - 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.

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.

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.
You might also be interested in Selenium IDE:

Related

Accessing a console application from web page

I've recently created two C# console applications. The first transforms a bunch of command outputs into an XML, and the second transforms the XML into a Word document using a template.
I'd like to know how I could get this onto the web, i.e having a web page where the command output can be uploaded, the two step conversion executed, and finally the Word document made available for download.
Should the web page be created in ASP.NET or are there other (better) options? Do I need to rewrite the console applications in some other format?
This question is fairly broad, with plenty of room for novel sized explanations, but here's a brief highlevel walk through of what likely needs to happen to achieve the proposed results (language agnostic):
Get a hosting provider that allows users to spin up their own machine (i.e. AWS).
Spin up a machine that is compatible with the "console" programs in question.
Install "console" programs on machine.
Install a programming language (i.e. Node.js, PHP, ASP.NET, even C# could do) on the machine.
Install a web server (i.e. NGINX, Apache) on machine, configure it to serve public requests and run with chosen language.
On server request, execute appropriate commands from within the chosen language. Languages typically come with a exec method (i.e. in node.js: require('child_process').exec(command,options,callback))
Get the results of said commands and send it back to the client. Alternatively (for downloads), write the result to a path on the system that is publicly available to the internet and redirect the user to that url (additional configuration might be required to make sure the browser downloads the file as oppose to just serving it).
The steps above should get you pretty close to that you want. As for your questions:
Should the web page be created in ASP.NET or are there other (better)
options?
The "better" options is whatever you feel most comfortable with at the moment, you could always change it later with reasonable effort (assuming that your "console" apps are not unsuspecting unicorns).
Do I need to rewrite the console applications in some other format?
No, unless you have strong reasons to do so (i.e. multi environment compatibility). You could also rewrite to significantly simplify (i.e. bypass working with a CLI and do everything in C#).
Try thinking through these high level steps, begin working on a implementation, and post more specific questions here on StackOverflow when you get stuck.
I hope that helps!

Accessing Environment Variables in flash

I know I cannot access environnment variables directly in Flash.
My project is a local swf file, run from flash player and not through browser.
The goal is to protect the SWF to be played from an unauthorized PC.
(this is my client requirements).
My idea was to embed it into an EXE (made in Delphi for instance) as activeX.
I am not sure it is the best solution.
I think AIR is even more complex to be done.
Besides, how to forbid the access of the SWF directly ?
Maybe embedding the swf any way ?
Any suggestions, tips are welcome.
regards
I'm going to preface this by saying that I don't think there's a 100% way to stop unauthorised access - if there was, there'd be no such things as pirated copies of windows, or flash. The best you can do is make it hard to hack.
Some suggestions:
You can actually access environment variables, by calling an external process in AIR, using NativeProcess (this link has a quick writeup: http://www.tikalk.com/js/get-windows-environment-variables-air-application) - but it's trivial to hack the .bat or add the env var
You can implement your own serial key system and give out keys to legitimate users. It would ideally need to be verified by a server call
You can code a "phone-home" server call - the app won't work without it. How you identify your users is really up to you; you could try via IP, but it's not perfect
You could disable local execution (check out SecureSWF), and run it online, behind a login wall
You could disable local execution, and run it via an intranet, so people in a company can use it, but not the general public
Depending on your app, on startup, you can download necessary files (content) from the web. This can either necessitate a login, or you can block unauthorised IPs. This is how Ubisoft DRM works on some of their games.
In a similar vein, you can download other SWF files that contain the actual logic of your application. These SWFs would only be stored in memory, never saved to disk
With all of these, the app can eventually be hacked open and modified (e.g. your server-check code could be removed, so the phone-home never happens). At the very least, run your SWF through something like SecureSWF (http://www.kindi.com/) to obfusticate the code before any public release.
It all comes down to how much effort you want to put into tackling the issue. For all the of suggestions that involve the internet, if the network is down, you won't be able to use your app, which understandably will cause frustration. For all of the suggestions that don't involve the internet, you will never know if it was successful or not.

How to set test URL in LoadTest in LoadAndPerformanceTestProject - Basic

This question is very basic if you previously used this tools, but I just spent 2 hours and havent figured it out, so please help.
It is the first time I try to test a REST service and how many concurrent users can it take. While LoadStorm looks like the best product for something like this, I want something free.
I began using the LoadAndPerformanceTestProject project in Visual Studio. I created a loadTest, as you can see in the image, but I have no idea how to set the url I want to test. (see image below)
Questions:
1) where do you set the url you want to test and the request parameters for my REST service?
2) is this tool just a programs that runs on my machine and makes requests to the server?
3) what can I do to run it in the cloud so I can get more accurate results? I have a MSDN subscription, and the URL I use is actually my project that is in Azure.
These are a lot of questions, but I don't see any tutorial online on how to use this feature. I saw this video enter link description here but unfortunately when I go to TEST in the menu bar, I have different options from the video - see picture bellow. In the video is seams like he doesn't have to add a LoadAndPerformanceTestProject at all.
First you need to create one or more Web Performance Tests. It's in this test that you define which urls should be hit in the test and how it should happen (GET, POST, loop, conditions, headers, ...). You can add a new Web Performance Test by simply right clicking your project, Add, New Web Performance Test.
After you created your test, simply add them in a scenario of your load test:
This should get you started. To get the most out of load testing I suggest you do some more reading about the topic because there's a lot more to it.
For running load test in cloud you can follow the links here
http://www.visualstudio.com/get-started/load-test-your-app-vs
Do let me know if you need any help.

How to profile my production web application?

I have a blog I made. Recently, I've been noticing some performance problems. I'm getting about 400ms waiting times for the index page. I think this is quite high. When I first deployed it(with less features, but still) I recall index load times of something like 80ms.
Now I would profile it, but the problem is that this only happens in my production environment. In my test environment, the index page only takes 10ms.
How do I go about profiling my production application? I use Apache+mono+mod_mono on Arch Linux with MongoDB. I have a similar test environment except I use xsp.
I'm unsure of where to look: my code, Apache's configuration, or MongoDB? How can I profile my production server to figure out why it's so much slower than my development environment?
Tough to be specific without details, but here's a shot at a general guide:
First I would recommend using something like Firebug for Firefox - there are equivalents in other browsers, but this is my old go-to tool for this kind of thing. Enable it and got the Net Panel view for a waterfall diagram that will show you a list of every object that is loading on a page (you might have to refresh) - it will also have a blue showing the render event (when the page becomes visible).
The waterfall should make it pretty obvious where the slow pieces of the page are and armed with that information you can go to the next stage - figuring out why particular pieces are slow.
If plugins are not your thing, or you suspect that it could be something local to yur machine causing the issue, then take a look at: http://www.webpagetest.org/
That will give you the ability to remote test from different locations, different browsers, speeds etc. and give you similar detailed results.
If it is a static file being fetched, look at network problems, Apache as a cause. If it is dynamically generated then look at Apache, ASP, mongodb etc.
For Apache, what do the access logs say is the response time for the index page? Assuming Apache 2 or newer, make sure you have %D (and %T if you like) being logged so you can see the time taken to serve the page (from the Apache perspective) at the required level of details. For more info on that, take a look at the LogFormat directive.
I can't help on the ASP/Mono side, not my thing, but adding debug statements at various points to track the index page generation (assuming it is dynamically generated) would be a pretty standard approach.
For the database, MongoDB by default logs only "slow" queries that take >100ms - if you are trying to track down a sub-100ms response time issue via the logs you will need to adjust that or you will likely get very little. That can be done as follows:
> db.setProfilingLevel(0,20) // leave profiling off, slow threshold=20ms
You can also adjust it as a startup parameter (--slowms) to the mongod process. More information on profiling, which may also help but has overheads, can be found here:
http://www.mongodb.org/display/DOCS/Database+Profiler
I'd suggest you have a look a Sam Saffrons Mini Profiler. If you use it in your site, it allows you to turn on profiling on production.
By adding sufficient instrumentation to your code, you should then be able to identify which bit is taking the time and then focus your efforts there.

ViewState and Web Load Testing

I'm trying to do load testing against an ASP.NET web site and I need to be able to parametertise field value of a page to test different code paths.
I had great success with JMeter when load testing a JSP web site before. However, because ASP.NET encodes all form values in the ViewState, changing control values does not really work.
I Googled this problem and people said the web testing tool in Visual Studio Team Tester Edition works well with ASP.NET pages. However, it cost quite a bit so I am just wondering does anyone know how to get around the ViewState issue with JMeter or WAPT?
I've used WebLoad before. Its scripting language is basically JS, so you may be able to find controls on the page using JS and invoke them as part of your load script.
WebLoad is free.
I've figured out how to do this, basically you cannot simply record a static script with JMeter. What you need to do is to record a request, send it, capture the viewstate in the response and send the viewstate back in next request.
If you need more details, I've documented how to do this along with some screenshots on my blog post
As webapps get more complex (ViewState, AJAX, etc) it is tougher and tougher to use traditional load testing tools. That's because they try to jam a ton of virtual users on a very small amount of hardware resources.
My company, BrowserMob, took a different approach. We build a load testing service that uses real web browsers to drive load. Your scripts end up being essentially functional tests (specifically Selenium scripts). My background has been in Selenium for some time (I created Selenium RC and founded OpenQA.org), so as soon as cloud computing made it possible to rent the 5TB+ of RAM necessary to do this, I jumped on the idea :)

Resources