How to Open Print Friendly Page Windows? - asp.net

Our users can currently select a number of funds from a page and go to another page to see the funds compared on a chart. I now have to present the user with an option to produce a print-friendly fact sheet page for each fund in the chart.
The requirement is that each page will open in a new window (or tab), and be minimised so as not to be 'too intrusive' when they're opened. Can somebody suggest how I could go about this? This also means that the user will have to go to each window or tab to print the page.
They also want the print dialog box open in each of the new windows so the user doesn't have to open it. Is this possible, for the print dialog to open at the page load? If so, can somebody suggest how - JavaScript?
I disagree that (up to) 10 new windows can ever be anything but intrusive! Ideally I could send these new pages directly to the print queue. Is this possible?
Otherwise, I could Generate a page dynamically for each fund, strip out the contents of the page body and add the content for that fund to a large single page print-friendly factsheet. Does anyone have experience in this kind of work? Any pointers?

several points
you cant control new tabs vs new windows, this is a browser setting.
if its tabs, you can only have one print dialog per browser instance (depends on browser, but generally speaking). It tends to be modal.
you can call window.print() on page load to trigger the print dialog automatically, but its not very user-friendly
Whats the problem with creating a print friendly css and simply having a print button on the page that calls window.print();

Related

When to use wait.until in Appium?

I just started developing a test automation for an iOS app using Appium. I have to click several buttons in the app one after another with different XPath/Accessability ids.
I wondered, when to use the wait.until(ExpectedConditions.visibilityOf Element) expression.
Example:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//XCUIElementTypeApplication[#name=\"app\"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeTabBar/XCUIElementTypeButton[3]")));
Should I check every time before I click a button if this button is actually visible or existing on the current state of the app or is this just unnecessary and time-wasting?
In my opinion, you should use ExpectedConditions in two case:
Screen load takes long, so you not ending up trying to click something that has not loaded yet. If you find your tests flaky (sometimes pass some times fails) then this probably the main reason why it happens
If you have something like ajax on your screen you want to make sure the data is changed on the page. (Example is you created a post on Facebook, and want to make sure content displayed)

Is it possible to persist Drive Picker widget settings across pages?

I have 2 pages in my app. Page 1 allows the user to select a pupil and then the app shows Page 2.
On Page 2 I have a Drive Picker widget that allows the user to choose images that will be copied to a specific folder (depends on what was selected on Page 1).
If the user closes the picker on Page 2 after picking files and then opens it again without visiting Page 1 first, the Drive Picker remembers which specific folder they had navigated to and allows them to continue.
If the user visits Page 1 again first to select a different pupil and then comes back to Page 2 and uses the Picker, it seems as if the Picker gets reset and shows the user the root of their Drive again. I want to avoid this behaviour so that the user can continue to select files from their last visit (in the same session) to Page 2.
Is there anyway to access the last visited folder of the picker and store that say in a page property and then make the picker use that property the next time it is opened?
I have become a little confused as well with the options that are available to the widget and the options that are surfaced through the result object. I confess that I've tried to search stack overflow for more information on how to use result object, but cannot surface much so all of my scripts use the widget.selectedDocuments way.
You can use sessionStorage() to keep variables between pages.
It is a client side function and does not support "custom action" as far as i know, but the following functions can fix that.
function get_ss(name){return sessionStoreage.getItem(name);}
function set_ss(name, val){sessionStorage.setItem(name, val);}
when navigating from page 1 you can use a custom action to get pupil and set it in sessionStorage then navigate to page2
"Custom Action=" set_ss("pupil", app.pages.Page1.decendents.PupilName.value); app.showPage(app.pages.Page2); //going from memory on the navigation code
You can add "var pupil = get_ss("pupil");" where ever you need it from there.

Visual Studio Performance Coded UI - Popup Window broken, Because Web Test Recorder is causing it to open in a full window

I have ASP.net webform that opens a popup window. example window.open(""); The POPUP window closes itself when a hyperlink is clicked inside. [Like search for person by name, select person and pass the person back to the parent form.] Then posts back from the javascript. When it is a full window[not a popup], It does not postback or close the window. When not recording for a test, it opens the modal popup and closes\posts back fine.
The real problem is you cannot finish a test if you cannot close the popup and transfer the selected values back to the parent form.
How do I stop the test recorder from opening the window in full screen. Or how can I make the popup perform normally[close and postback the data] when windowed.
Here is a little info. In the popup I force a postback after closing the window here.
function CancelPopupWindow() {
self.close();
//Here to force a post back on the parent. This is used to automatically save the data
window.opener.__doPostBack('', '');
}
Anyone else hating this problem. Please vote for a fix at User Voice.
https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/16390135-make-web-performance-popup-javascript-dialogs-open
There is a workaround. The program Fiddler can be used to record the entire test then use Fiddler's menu => File => Export sessions => All sessions => Visual Studio web test and then follow the remaining prompts. That will produce a .webtest file. Like any other .webtest file it will probably need work to resolve dynamic data etc.
A variations is to record as much as you can with Visual Studio. From the start of the test up until the problem occurs. If possible you could also record the completion of the test. So just the piece with the problem is omitted. You can also record the problem part with Fiddler and save that. Now you have two or possible three .webtest files that cover the whole test. Now just merge them. With the Visual Studio web test editor you can copy requests and paste them into other tests. (Or else where in the same test. You can also drag requests in a .webtest to reorder them.
The purpose of recording the steps that use JavaScript is to learn enough of what they do so as to replicate enough of their action for the web test. So mixing pieces from different recordings is valid.
The .webtest file contains XML and so can be edited with a text editor. I often make changes in this way, for example to replace many occurrences of the same string with a context parameter. Editing at this text level can help when merging pieces from multiple files. Just be careful to make backups. Visual Studio just gives refuses to load .webtest files with mal-formed XML.

window.open in web application for iPad running in fullscreen replaces the existing window

I am writing a simple (ASP.NET) web application for the iPad. It is written and works well however one feature is it serving up PDF files (among others). To do this I used window.open to open the file.
When this is done in Safari, it works perfectly. You click the button, the file opens in a new tab; you can then close the tab to return to the previous web page.
However now running the application in fullscreen mode - i.e. with the appropriate "meta names" set and from a shortcut on the home screen - when you click the button to load the file, it loads fullscreen with no means to get back to the last page.
Because it is a file, not a webpage, I can't put a "Back" button on, and when you press the iPad button it simply closes the whole thing.
I know this has been asked before and I have read a number of similar questions - the closest of which was this:
https://stackoverflow.com/questions/9168236/web-app-hyperlinks
If at all possible, it would be far preferable (thanks to the control library I am using) that the button click is done with javascript - it is not easy to set the link href.
The upshot is I really I just want to create a new window from within a fullscreen iPad web application, or allow the "back" navigation somehow...
Is this possible?
Thanks!
Create an iframe on your page rather than using an window.open and set that as the target.
That way your pdf would open within your existing window.
Use some client side javascript like jQuery to style it like a dialog window.

navigateToURL ... set modal property

When a user clicks a button, I need a separate browser window to popup. How can I set the modal property of the application? (ie, when a popup window opens, the main application is disabled until that popup is closed ... I need to use a browser window rather than a popup window, but can't figure out how to disable the main application)
PopUpManager.createPopUp (this, navigateToURL( url, "http://www.google.com" ) , true );
thanks!
[[Updated Answer]]
Ok, my modal dialog looks like so:
cg = mx.managers.PopUpManager.createPopUp(this, ChoiceGrid, true) as ChoiceGrid;
PopUpManager.centerPopUp(cg);
But, what I would do instead of what you're asking, is embed an IFrame in the modal popup. This is exactly what we're doing in our app to collect CC data (well, not the popup part, just the IFrame bit. http://code.google.com/p/flex-iframe/
This way, you have the standard modal dialog you're looking for, AND an internally managed 'view' out to your checkout server. Something like this:
<code:IFrame id="iFrameWithJSfunctions"
src="{checkoutURL}" />
The flex-iframe is pretty easy to work with, for the most part. You shouldn't have many problems with it.
[[Original Answer]]
I'm not sure you need a PopUp to do this.
Why don't you simply do:
navigateToURL(urlRequest,"_blank");
instead?
You should think of a Flex App as a self contained entity. The PopUpManager is designed to create Windows (Panels / any UIComponent) that reside over another component inside the SWF. It does not create items that pop up out of the SWF or in new browser windows.
navigateToURL could be used to create a HTML pop-up from your Flex application. However, there is very little--if any--communication between the SWF and the browser pop up. And there is no way to make a modal pop-up.
You might investigate performing an ExternalInterface call and creating your new pop up in JavaScript. Here is an article about creating modal windows in JavaScript. Before going too far down that road, I would think carefully about your requirements. How would feel if one browser window popped open another browser window and prevented you from doing any browsing until you addressed the issues in that window. Or to put it another way, how would you feel if Microsoft Word opened a word document and wouldn't let you edit any other document until you shut down the first one? I'd be pretty upset.
Modal application dialogs are one thing. And the PopUpManager allows you to create those. I would consider Model application windows a bad UI decision.

Resources