While doing e2e testing using protractor ,a requirement comes to load a page.I tried browser.get,But that reloads the page resulting in cache clear.Getting ERROR as
Failed: Element not found in the cache - perhaps the page has changed since it was looked up
How to load a page without reloading it in protractor?
If you question is about routing in an angular app, then you can try with browser.setLocation().
browser.get('http://angular.github.io/protractor/#/tutorial');
browser.setLocation('api');
// You now will be in http://angular.github.io/protractor/#/api without any page reload
Reference: Protractor API browser.setLocation
Protractor's browser.get will always navigate to a RESET_URL=data:text/html, <html></html> before navigating to the page you requested. There are a couple options to get around this:
browser.driver.get(url) will use the webdriver native command, and bypass protractor's reset url. If you go this route on an angular page, you will want to add in a waitForAngular() before the command so that you wait for the original page to settle before navigating to the new page.
browser.ignoreSynchronization = true in your test will essentially turn browser.get into browser.driver.get and bypass the reset url. The downside here is that your entire test would now be ignoring angular synchronization.
Source: protractor/lib/protractor.js
Related
I am hosting a flutter web app, which involves the initial url having query parameters (e.g. https://mysite.web.app/?k=ZF6K5UA7X3Jk9HJanla3). I use the url_strategy package to get rid of the #, however when the site loads, the query params are stripped off, leaving the bare-boned "https://mysite.web.app". I have got around the functionality aspect by storing the param as a cookie variable, however it is not ideal.
Is there any way to re-instate the params programmatically in the url bar of the browser? The reason for this is for both (i) giving the user the option to share the original URL, and (ii) allow them to add the app to their mobile device screen as a PWA (with the original full url).
Any suggestions welcomed.
I resolved this via the implementation of go_router. With the combination of state.queryParams and Router.neglect(context, () => context.go('/?k=$myOriginalParam')) (from any pages that wanted to go back to the original route with no browser back button history), I can retain the query parameter in the browser bar successfully.
I am trying to debug a webpage with chrome developer tools and the page redirects to a pdf file after it loads. I checked JavaScript files and there is not any place that we redirect the page. I cannot find any related message in developer tool console or network tab.
I activated event Listener Breakpoints -> beforeunload but it stops at an external js file (Placeholders.js) which is not related to redirecting.
Also, preserving Logs in network tab does not help me on finding root cause of redirect.
I am wondering how can I find the source of this redirect?
UPDATE: There is not any "refresh" meta tag in the html code.
There are a couple of things you can do. You can use the Event Listener Breakpoint -> Load - unload and then when it breaks in the 3rd party library, right click and select Blackbox Script. The next time you play through the code, it should only break in your own code (assuming there are no other 3rd party libraries to blackbox).
Another option is to go to the Network tab and check the Preserve Log checkbox. This will persist all requests between page loads/navigation, so that you will be able to find the network request that returned the PDF response.
Environment:
IE9 with Group Policy applied and an automatic proxy script, which defines a set of internal (using DIRECT) and external sites are redirected to a proxy.
Desired behaviour:
Starting from an internal web site page, clicking on an external link makes IE navigate to the external page directly.
Problem:
If IE is not run as administrator, IE redirects first to about:blank for about a half a second, and then to the external page.
This is a problem when we try to prevent navigation to certain URLs by cancelling the BeforeNavigate2 event in a Browser Helper Object.
The problem is that when we try to prevent the navigation, the browser shows the about:blank page instead of staying on the original page.
I wrote relatively simple web app in Spring MVC. I have following multipage forms:
Fill in
Check preview and eventually go back to 1. by form button or back button in your browser
Confirm
I used annotation #SessionAttributes and everything goes well, besides of going back to edit form after preview.
Then I have an information that document has expired in browser and I have to renew my POST request hence creating new objects. I resolved this problem by creating another method which loads view with form and loads there information from session, but still I can't use 'back button' in my browser. I would like to avoid javascript in this problem. Any ideas?
EDIT: I can see when session is active header is always set to 'no cache no store', maybe there is a way to configure Spring Session to enable cache and store? I searched but didn't find anything helpful.
I am trying to add google gadget into FlowPanel(or HTMLPanel), but after a host page is loaded it navigates away from my page and shows gadget in a new page, if i click browser's back button it loads host page and again navigates away to new page to show the gadget.
Here is the code:
String code="here_goes_scrip_tag_for_gadget";
flowPanel.add(new HTML(SafeHtmlUtils.fromTrustedString(code)));
What am i doing wrong, please help.
UPDATE
The above code to load script was wrong, i've modified it as following:
FlowPanel gadgetContainer = new FlowPanel();
Element script = Document.get().createScriptElement();
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "http://www.gmodules.com/ig/ifr?url=http://digg.com/goog/ig.xml&up_user=&up_thumbnail=1&up_filter=0&up_num=5&up_type=popular&up_refresh=0&up_tab=0&up_offset=0&up_pagination=0&up_business=true&up_entertainment=true&up_gaming=true&up_lifestyle=true&up_offbeat=true&up_politics=true&up_science=true&up_sports=true&up_technology=true&up_world_news=true&synd=open&w=320&h=200&title=Digg&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js");
gadgetContainer.getElement().appendChild(script);
But it still doesn't work.
For solving this problem in general, check out the com.google.gwt.core.client.ScriptInjector class - it has two methods that allow you to inject scripts into the page in a cross browser way. The way you are attempting to inject the script content won't work cross browser.
Looking specifically at your gadget case, I'm guessing that the script you are loading has code in it to prevent it from being loaded into another page. Have you tried to use a plain html page that references that script tag? If the same thing happens, see if you can see where in the script file the page reassigns window.location.