Is it posible to produce onClick event with JMeter? - onclick

I'm trying to create sress test with JMeter and herefor is absolute required to produce mouse onClick-event for some elements. But I cannot find any possibility to produce onClick-event with JMeter.

jMeter doesn't evaluate the HTML or JavaScript that is returned by the webserver, it just captures it.
So, no, you can't do an onClick event with jMeter. What you can do however is extract the url that the onClick event would trigger using the Regular Expression Extractor, and then feed that url to a new HTTP Sampler.

Jmeter is designed to simulate the server traffic (e.g. HTTP) generated by client (e.g. web browser). It does not simulate the entire browser. So no, you cannot produce or simulate the onClick() event, but you probably can simulate the traffic generated by that event.
To do this, you'll need a tool to capture the requests sent to the server when this onClick() event happens. Then you can model those requests in your JMeter script, just like you've modeled other requests.

JMeter is intended to run load (or general connectivity) tests against a back end service like, for example, a web application running on an application server like Tomcat, Weblogic, WebSphere, etc..
If you would like to 'drive' a browser in a test environment, take a look at tools like Selenium
Since you mentioned JMeter, I'm assuming you may want to stick to Java (or the JVM, at least) so you could look at Geb as an alternative to Selenium.
There are many other similar tools, though. Have a look at: http://alternativeto.net/software/selenium

Related

How to Automate Web Analytics testing?

Omniture/SiteCatalyst's code is integrated onto the webpage to collect the analytics in our firm.
Current process: SiteCatalyst id deployed by pasting HTML code onto each page of the website. This HTML code contains variables and other identifiers that facilitate the data collection process. These variables may be dynamically populated with server or application variables. The code snippet also calls the JavaScript library file, which contains SiteCatalyst-specific JavaScript functions used during metrics collection.
We use Add-on's like Charlie, HTTP Post, DigitalPulse Debugger to Test if the code inserted has accurate values corresponding to it. This process is time consuming and tedious.
How to Automate this process? Any help would be appreciated!
Example 1:
Click here to send a page view
s.pageName="New Page"
s.prop1="some value"
void(s.t());
Example 2:
s=s_gi('myreportsuiteid');
s.linkTrackVars="prop1,eVar1,events"; s.linkTrackEvents="event1";
s.prop1="some value"; s.eVar1="another value"; s.events="event1";
s.tl(this,'o','My Link Name');
There are a few different ways to automate testing. I've been looking into it lately myself. So far I'm looking into Selenium, Zombiejs and Phantomjs. You can search for "headless testing" which basically let's run code as a browser and test conditions on the page you visit.
Here's a good place to start https://github.com/ariya/phantomjs/wiki/Headless-Testing
Using these platforms, you could easily set pages to automatically validate if the SiteCatalyst code is firing, page names are correct, click events happen etc.
Selenium is an enterprise product whereas the JS frameworks would be more of a development effort.
we usually do this using a more customizable proxy application called Fiddler which we use to capture all the traffic sent from our brower.
Fiddler has an internal scripting language that let you make any type of check on the data passing in the Adobe Analytics call and highlight in the interface any bad call.

How to simulate timeouts with Fiddler

I have a C# script that HTTP POSTs to another server with WebRequest. I'd like to test how my web application would respond if the other server became unresponsive. What is the best way to do this without having to change any of my application code or configuration? Will Fiddler be able to cause timeouts for requests coming from my local IIS?
You can achieve it using the "Simulate Modem Speeds" rule.
Rules -> Customize Rules
Find the line that says "oSession["response-trickle-delay"]" and change it. Set it to 10000. It should be enough to cause time out. Save the file.
Rules -> Performance -> Simulate Modem Speeds (should be checked).
Note: Use ipv4.fiddler instead of localhost.
Can be achieved on specific responses where you want to intercept the response as well as simulating latency by using "AutoResponder".
"Enable Latency" checkbox and right-clicking any rule to pick "Set Latency" you can then adjust latency in millisecond values.
The other part of your question is "How do I get my service to use Fiddler", which has an answer here: http://www.fiddler2.com/Fiddler/help/hookup.asp#Q-IIS

Webdriver vs. browser

On the server side, is there any way to distinguish a request coming from an automated script from selenium webdriver vs. a request made by a physical user?
You could have webdriver set a specific cookie during its request, that way you know when you're dealing with a webdriver request.
Depending on the browser you're using or your implementation of the test, you could pass a header to the http request.
If you use chrome, you can build something to use ModifyHeaders extension. I'm sure you can use other similar things in firefox.
Another alternative is to use FiddlerCore in your testing framework and intercept the request and pass the custom header.
There are multiple other alternatives as well. Can you specify a little bit more where do you want to know who's running the test?

Any suggestions for good automated web load testing tool?

What are some good automated tools for load testing (stress testing) web applications, that do not use record and replay of HTTP network packets?
I am aware that there are numerous load testing tools on the market that record and replay HTTP network packets. But these are unsuitable for my purpose, because of this:
The HTTP packet format changes very often in our application (e.g. when
we optimize an AJAX call). We do not want to adapt all test scripts just because
there is a slight change in HTTP packet format.
Our test team shall not need to know any internals about our application
to write their test scripts. A tool that replays HTTP packets, however, requires
the team to know the format of HTTP requests and responses, such that they
can adapt details of the replayed HTTP packets (e.g. user name).
The automated load testing tool I am looking for should be able to let the test team write "black box" test scripts such as:
Invoke web page at URL http://... .
First, enter XXX into text field XXX.
Then, press button XXX.
Wait until response has been received from web server.
Verify that text field XXX now contains the text XXX.
The tool should be able to simulate up to several 1000 users, and it should be compatible with web applications using ASP.NET and AJAX.
JMeter I've found to be pretty helpful, it also has a recording functionality to record use cases so you don't have to specify each GET/POST manually but rather "click" the use case once and then let JMeter repeat it.
http://jmeter.apache.org/
A license can be expensive for it (if you dont have MSDN), but Visual Studio 2010 Ultimate edition has a great set of load and stress testing tools that do what you describe. You can try it out for free for 90 days here.
TestMaker by PushToTest.com can run recorded scripts such as Selenium as well as many different languages like HTML, Java, Ruby, Groovy, .Net, VB, PHP, etc. It has a common reporting infrastructure and you can create load in your test lab or using cloud testing environments like EC2 for virtual test labs.
They provide free webinars on using open source testing tools on a monthly basis and there is one next Tuesday.
http://www.pushtotest.com
There are a few approaches; I've been in situations, however, where I've had to roll my own load generating utilities.
As far as your test script is concerned it involves:
sending a GET request to http://form entry page (only checking if a 200 response is given)
sending a POST request to http://form submit page with pre-generated key/value pairs for text XXX and performing a regexp check on the response
Unless your web page is complex AJAX there is no need to "simulate a button press" - this is taken care of by the POST request.
Given that your test consists of just a 2-step process there should be several automated load packages that could do this.
I've previously used httperf for load testing a large website: it can simulate a session consisting of several requests and can simulate a large number of users (i.e. sessions) simultaneously. For example, if your website generated a session cookie from the home page you could make that the first request, httperf would then use that cookie for subsequent requests, until it had finished doing the list of requests supplied.
What about http://watin.sourceforge.net/ ?

Multiple replies from server for one client request

This may be a dumb question - and the title may need to be improved... I think my requirement is pretty simple: I want to send a request for data from a client to a server program, and the server (not the client) should respond with something like "Received your request - working on it". The client then does other work. Then when the server has obtained the data, it should send an asynchronous message (a popup?) saying "I've got your data; click on ... (presumably a URL) to obtain data". I have been assuming that the server could be written in Java and that client is html and JavaScript. I haven't been able to come up with a clean solution - help would be appreciated.
Try to employ "Websocket Method" by using "SuperWebSocket" for server side, and "WebSocket4Net" for client side. It is working perfectly for my current project.
Most of the work invovles the server being asynchronous. To do this you must
Have an ajax call to the server that starts a job and returns a confirmation the job has been started.
A page on the server that will return whether or not any jobs are complete for a user.
Have an ajax widget on your client side that pings that page on teh server every so often to see if any jobs have been completed. And if so make a pop up.
This is the only way unless you use Flex data services.
Are you trying to do this on the HTTP protocol? It sounds like you're talking about a web application here, but it's not clear from the question. If so, then there are a variety of techniques for accomplishing this using AJAX which collectively go under the name "Comet". Depending on exactly what you're trying to accomplish, a number of different implementation, on both the client and server side, may be appropriate.
for pure java i suggest something like jgroups (client+server are java)
for html, you should use ajax - there you have a timer that checks every X seconds
Nowadays you have an alternative technique to use: Websockets. These are used for server->client communication without polling or ajax-style delayed responses.

Resources