I am attempting to capture client/server response time as recorded by the browser using Selenium WebDriver. My selenium test cases are written in Java. I don't control the code in which I am testing and have tried a variety of solutions as laid out below but none of them meet my requirements 100%.
At the end of the day, I am looking to be able to surround a test step with start() and stop() logic and save the client/server response time as recorded by the browser to a database for reporting.
If I am missing something obvious, please suggest a different approach!
Things I've tried:
1.) Manually surround the test step with start() and stop() timer logic.
PROS: Simplest solution and it works for both page loads and ajax calls.
CONS: Does not capture what the true response time from the browser and if there is unusually long wait time on the Selenium side, it falsely reports the numbers. It also considers things like user input as part of the transaction which I don't want. I don't necessarily control the Page Objects I am dealing with so it is not an easy work around.
2.) Using Navigation Timings API
PROS: This works great for page loads
CONS: Does not work for AJAX calls. AJAX calls are simply added to the overall page load time and the getEvents() call is not available in Firefox for me to attempt to manually calculate the ajax time.
3.) Using Browser MOB
PROS: Can surround a transaction, not just a request and save it in HAB format.
CONS: I had high hopes for this but the numbers are not reported from a browser perspective and thus are just as inaccurate as (1). There is also setup overhead creating a proxy server and the resulting HAB file does not have client/server response times broken down.
4.) Firefox and Networking Export plugin
PROS: Nice automated solution
CONS: The export functionality creates a new file for each request but can not aggregate multiple requests into a transaction. There is also no way in which to specify the file name so it makes it impossible to attempt to read in the files which are simply appended with a timestamp.
5.) Relying on "framework" response times.
PROS: Works and at at least on the surface appears accurate.
CONS: Does not work across frameworks and thus can not be considered a scalable solution for a busy production site where multiple frameworks are in use.
Things I haven't tried:
1.) Javascript injection
PROS: Perhaps I could inject javascript like the boomerang plugin into the site to measure response times.
CONS: May be difficult and I worry about losing my injection through page events which I may not be aware of or control.
2.) Relying on HTTPWatch plugin
PROS: Appears to do what I want
CONS: There is no Java plugin and I don't know if I am up for creating a COM based integration layer when I don't even know if it will suit my needs. I do like the ability to start/stop transactions though vs. individual requests.
3.) YSlow, Google Page Speed and WebPageTest
PROS: Seamless?
CONS: Non-starter since I am behind a firewall although I am intrigued on how they attach to the requests.
Related
Having an existing GWT what kind of pattern should I follow if I want to display to all the users a system wide message like:
System is undergoing maintenance, excuse the potential slowdown here and there.
For new users loading the app I can think of ways of pre-populating their initial page, but for users that already have loaded their SPA page then I cannot think of any elegant way to push the message.
And an equally elegant way to retract the message, when the "maintenance" ends some time later on.
Should I use a timer and ask the server a list of messages to display, and have it run in the background...?
Thanks!
This is IMHO the old way to do this kind of things (polling), but the elegant and modern way is to use server side events via html5 (using something like atmosphere) or any websockets simple gwt library), etc. If you follow this pattern, check also this other related question.
If you don't have other instant server-to-client messages to receive, a simple polling mechanism is most easy to implement and understand. More complex solutions that support instant server-to-client messages are websockets / server side events / long polling.
Also note:
If you are using GWT RPC Services, swapping the backend for a running client will result in a IncompatibleRemoteServiceException, if ...
[...] One of the types used in the RemoteService method invocation has had fields added or removed. [...]
The message of this exception reads "This application is out of date, please click the refresh button on your browser." You might want to check for this Exception in the onFailure methods and (ask the user to) reload. See the link for details in which other cases this exception occurs.
I have a Spring MVC project in Java. This web app can be accessed by multiple users in different browsers. I haven't coded any session bean in my program.
Now I want to 'crash'/'timeout' the browsing of one of the users, while other users will go on with their normal expected browsing. I want to do this to see if this action has any effect on the shared variables.
What kind of coding I need to do for this? Thanks in advance!
It is not at all clear what you are trying to achieve here, but I'm assuming that you are doing this as an experiment ... to see what happens.
You could modify the webapp to implement some special request, or request parameter, or request parameter value that tells the webapp to crash or freeze the request being processed. Then send that request from one browser while others are doing "normal" things.
Whether this is going to reveal anything interesting is ... questionable.
Another interpretation is that you are aiming to include timed out requests and other things in your normal testing regime. To achieve that, you would need implement some kind of test harness to automate the sending of requests to your server; i.e. to simulate a number of simultaneous users doing things. There are various test tools for doing that kind of thing.
I'm working on a site containing real estate listings in Spring MVC. I would like to prevent scripts to steal the content by scraping the site. Does anyone have experience with techniques that can easily be plugged in to a spring mvc environment?
User-agent is too simple to circumvent.
One idea I had was to keep track of two counters on the serverside.
ipaddress --> (counter xhr request, counter page request)
the counter page request is increased with a filter
the counter xhr request is increased on document ready
If a filter notices the two counters are totally out of sync, the ip is blocked.
Could this work or are there easier techniques?
Cheers
edit
I am aware that if scrapers are persistent they will find a way to get the content. However, I'd like to make it as hard as possible.
Off the top of my head:
Look for patterns in how your pages are requested. Regular intervals is a flag. Regular frequency might be a flag (four times a day, but at different times during the day).
Require login. Nothing gets shown until the user logs in, so at least the scraper has to have an account.
Mix up the tag names around the content every once in a while. It might break their script. Do this enough times and they'll search for greener pastures.
You can't stop it at all, but you can make it harder as much as possible.
One way to make it harder is change your content URL very frequent base on time with appending some encrypted flag in url.
Some of suggestion are in given link.
http://blog.screen-scraper.com/2009/08/17/further-thoughts-on-hindering-screen-scraping/
http://www.hyperarts.com/blog/the-definitive-guide-to-blog-content-scraping-how-to-stop-it/
Load the content via ajax.
Make the ajax request dynamic so they cant just go and scrape the ajax request.
Only sophisticated scrapers support execution of java script.
Most scrapers dont run the pages through a real browser, so you can try to use that to your advantage.
I recently watched several Google I/O videos where Google developers present GWT with respect to performance and security. In that video the speaker makes mention of several GWT-isms:
Client-side request "batching"
"Disposability"
The pursuit of GWT app "statelessness"
With respect to "batching" it seems like GWT can be configured to queue-up server-side RPC calls and send them all at once (instead of many tiny, performance-hindering calls). Unfortunately, I'm just not seeing the forest through the trees here: doe GWT handle batching for you, or do you have to write the logic that performs this bundling/batching? If you have to do it, what kinds of calls can/should be bundled? How do you know when its time to fire the batch off?
In GWT lingo, what does it mean when someone says:
"Clients and servers are disposable"; but
"Views" are not disposable
How does this concept of "batching" and "disposability" relate to GWT app "statelessness". By that, the speaker defined statelessness as:
Browser embodies the session (?!?!)
Server is stateless - except for caching (?!?!)
Client never notices a restart (?!?!)
If someone could help give me concrete understanding of these 3 items and how they relate to each other I think I'll start to "get gwt". Thanks in advance!
doe GWT handle batching for you, or do you have to write the logic that performs this bundling/batching? If you have to do it, what kinds of calls can/should be bundled? How do you know when its time to fire the batch off?
GWT-RPC has no batching mechanism. You can (relatively) easily add some by queueing "commands" in a list and then sending the list as a single GWT-RPC call. Some projects should do that for you with minimal effort (GWT-Platform for example).
RequestFactory on the other hand has batching built-in: you create a RequestContext instance and batch calls to it until you fire() it.
"Clients and servers are disposable"; but "Views" are not disposable
The first is related to statelessness (and, for example, with AppEngine, you don't control when a new server instance is created, shutdown or restarted: the server can disappear at any time, so don't keep state in memory).
The second is about performance: everything related to the DOM in the browser is slow, so constructing a new view (widgets stacked together) is heavy-weight (less so with Cell widgets though). As a result, you don't want to make them disposable, i.e. throw them away every now and then. You'll rather want to keep one view instance around that you reuse for the lifetime of the app.
Not exactly the same notion of "disposability".
Browser embodies the session (?!?!)
GWT is built of single-page apps. You can store state on the client simply in variables in your app; you don't need cookies or whatever to have the state shared between pages.
Server is stateless - except for caching (?!?!)
Storing session state on the server has a cost (state must be persisted –particularly if the server is disposable–, shared between servers –when you have a cluster / run in the cloud–, etc. you'll spend as many resources keeping existence of your session state as doing actual business logic).
Client never notices a restart (?!?!)
HTTP is a a disconnected protocol. If the server is restarted, the client won't know about it, and it shouldn't have to know about it.
If someone could help give me concrete understanding of these 3 items and how they relate to each other I think I'll start to "get gwt".
It's not about getting GWT, it's about getting the Web and getting single-page webapps, and how to scale them.
Whether they're made with GWT or jQuery on the client-side, and Java or Python or .NET on the server-side doesn't matter.
Read about REST, it sums it all.
Are there any recommendations, best practices or good articles on providing integration hooks ?
Let's say I'm developing a web based ordering system. Eventually I'd like my client to be able to write some code, packaged it into a jar, dump it into the classpath, and it would change the way the software behaves.
For example, if an order comes in, the code
1. may send an email or sms
2. may write some additional data into the database
3. may change data in the database, or decide that the order should not be saved into the database (cancel the data save)
Point 3 is quite dangerous since it interferes too much with data integrity, but if we want integration to be that flexible, is it doable ?
Options so far
1. provide hooks for specific actions, e.g. if this and that occurs, call this method, client will write implementation for that method, this is too rigid though
2. mechanism similar to servlet filters, there is code before the actual action is executed and code after, not quite sure how this could be designed though
We're using Struts2 if that matters.
This integration must be able to detect a "state change", not just the "end state" after the core action executes.
For example if an order changes state from In Progress to Paid, then it will do something, but if it changes from Draft to Paid, it should not do anything.The core action in this case would be loading the order object from the database, changing the state to Paid, and saving it again (or doing an sql update).
Many options, including:
Workflow tool
AOP
Messaging
DB-layer hooks
The easiest (for me at the time) was a message-based approach. I did a sort-of ad-hoc thing using Struts 2 interceptors, but a cleaner approach would use Spring and/or JMS.
As long as the relevant information is contained in the message, it's pretty much completely open-ended. Having a system accessible via services/etc. means the messages can tap back in to the main app in ways you haven't anticipated.
If you want this to work without system restarts, another option would be to implement handlers in a dynamic language (e.g., Groovy). Functionality can be stored in a DB. Using a Spring factory makes this pretty fun and reduces some of the complexity of a message-based approach.
One issue with a synchronous approach, however, is if a handler deadlocks or takes a long time; it can impact that thread at the least, or the system as a whole under some circumstances.