wait until the page is loaded - robotframework

In Robot Framework, does any keyword in any library implement this? Open Browser and Go To just go to the requested URL but don't wait until the page document is fully loaded.

Have a look at this discussion. You don't really need to wait for anything apart from Ajax.
In case you are using Angular, have a look at extendedselenium2library that implements waiting for Angular actions with every keyword.
If you are not using Angular, but you know which Ajax action you expect will fire before you can proceed with your test, have a Wait Until Page Contains Element or Wait Until Element Is Visible keyword with a selector for an element that is specific for your ajax request.

Related

Invoking script on Listening the requestcycle start and removing the script at the cycle end

What all possible way to call JS or CSS in onBeginRequest() and onEndRequest() of AbstractRequestCycleListener class of Wicket?
Actually, i want to perform some action at client side using JS or Css at every request made and undo the action on the request end, I want to do this at application level and not component specific.
You can do this easily for Ajax requests. See AjaxCallListener's onBeforeSend() and onComplete() methods. Documentation is available at https://ci.apache.org/projects/wicket/guide/7.x/single.html#_ajax_request_attributes_and_call_listeners
For normal (non-Ajax) requests this is not that trivial because the complete page reloads and thus your JS/CSS is unloaded with Page1 and reloaded with Page2.

Staying on the same page in Spring

I'm using Spring and would like to find out if there is some technique that can be used to stay on the same page. So, to be more clear, after you click on a link and the handler executes, there is some condition which dictates that the browser should remain on (or be redirected/forwarded to) the page the browser was currently on. Beehive, which is built on top of Struts, has a way to do this and I'm wondering if Spring has something similar.
It really depends on the use case. Are you submitting a form or something similar that could be submitted through XHR instead? If you can't use XHR, a simple solution is to have the controller return a view to the current page, possibly with some additional state information.

ASP.Net save after hyperlink is clicked

I have a requirement to call a save method, that persists a model/object in the session, when the user leaves the page.
The page has various links that do not raise a postback but just perform a redirect. Are there any ASP.Net page life cycle methods I can hook into to perform the save without requiring a postback?
One solution could be to perform an asynchronous POST request (without waiting for a response) when the window is being unloaded:
An example using jQuery:
$(window).unload(function() {
$.post(location.href, $(document.forms[0]).serialize());
});
Although you will probably need to use a slightly different method for Chrome (found on jQuery forums):
It looks like the only way to get the
Ajax request to go through in Chrome
is to use the non-standard event
onbeforeunload. Chrome evidently
doesn't wait long enough to send the
Ajax request using onunload. It does
however wait for alerts...
Well that depends.
If you need to save values when the person leaves the page, then thats kinda hard.
What you can do, is to wrap all your links in some jquery, that says like:
Issue a Ajax Call, to AjaxSave.aspx, then it is completed, then window.location to the links href attribute.
BUT, that will only work if the person clicks on your links, not if the person just closes the browser or something.
You can also take the route to just save the stuff offen, so every time the person issues a post back, you just put the stuff in session. But that will mean that values changed from the last postback to the navigating away from the page is lost - don't know if that is an issue.
The last thing is to do like StackOverflow is doing. If you are editing stuff, it will show a warning when you leave the page, and then you have to click okay, to navigate away from the site.

Easiest way to simply display confirmation that a webservice worked?

I'm calling an asp.net webservice from an ASP clasic page basically just with:
<a href='http://domain/webservice.asmx/command'>Command</a>
and when users hit that button it works but they're just shown an xml page. The function will either work or not so I was wondering if it'd be possible to just have a pop up box appear to tell them if it worked or not after they clicked it rather than redirecting them to an xml page.
I'd prefer to not have to use jQuery or another javascript library.
If that's not possible, is there any way to dress up the XML page? Currently it says 'This XML file does not appear to have any style information associated with it. The document tree is shown below.' at the top.
Also, the domain that the webservice is on is different to the domain that the website that's call the webservice is on. Not sure if that matters.
Thanks
Check out this MSDN Link on Calling A WebService From Javascript Using AJAX. No JQuery is required and it boils down to having to use the ScriptService attribute on your WebService method and adding a ServiceReference in a ScriptManager control. You can then easily call your WebService from Javascript and it will call another Javascript function when it finishes. It is in that response function where you can add your confirmation display.
be aware that this is a bad idea to let the user handle directly - web services are almost always called by your code rather than a client browser session. One reason is that raw error information would be hown to the client if there were a problem.
If you really want to do this, you can either:
Use AJAX (No framework required - just JS) or
You can make the webservice non-standard so it returns user-friendly content - perhaps by wrapping it in a website which calls the API behind the scenes and formats the response in a meaningful fashion.

Detect when JavaScript is disabled in ASP.NET

In the Render method of an ASP.NET web-control, I need to alter the output of the Html based on whether JavaScript is enabled or disabled on the clients browser,
Does anyone know the right incantation to figure that out?
The problem with using script to check whether javascript is enabled is that you only find that out after the script hasn't run.
Some solutions try the opposite - they use javascript to set a value and then supply Javascript enabled controls if that value is later detected. However, this fails with javascript-sometimes-enabled tools like the Firefox NoScript plugin.
A more robust solution is to always send the plain-HTML compatible control, and then have javascript run on page load to add the correct event handlers/extra DOM elements/etc.
However I don't know how this fits in with the ASP.NET approach takes to controls.
The noscript tag is used to define an alternate content (text) if a script is NOT executed.
EDIT: Hi Kieron, take a look at this link: Creating a Server Control for JavaScript Testing, and Detect if JavaScript is enabled in ASPX
The browser does not communicate Javascript availability with the request.
One thing that I have done, though I'm not sure it is applicable in your case, is generate the page as if Javascript is not enabled, then have some Javascript that turns off the HTML-only stuff and turns on the HTML-Javascript stuff.
You could also have the first page hit "phone home" via Javascript to record in the session whether Javascript is enabled or not.
This is a way to check when a form is being submitted.
https://web.archive.org/web/20210428071600/http://www.4guysfromrolla.com/webtech/082400-1.shtml
I dont think there is any Request property that will tell you when the page is first requested. There is a property that will tell you if the browser supports JS, but not if its enabled. See Here
What you need to do is this. After much testing and late nights, I decided to use the most simple solution. Drag a label onto the top of the page and make sure it reads "run at server". Then, for the Text attribute, put Text="This website requires Javascript". That should be the best answer. :D

Resources