This was something which was cracking my head for sometime.
I have a Web Page written in ExtJS+Java EE (Page A). I want to create a
new browser tab on Button click and show page B.
B does some operation and does a complete form submit.
The result of this form submit has to be displayed in A (Which is open all the while).
For Example:
In Page A, I search for the tests available in the my learning management system and display it in a grid.
When the user clicks on a test, a new window opens with the test's url (Page B).
Once the user completes the test he clicks the submit in B.
The results of the test is shown on the grid in Page A.
The big problem is that I done have much control over the Page B or its source.
Any suggestions much appreciated.
It sounds like you would need to do a window.open('Whatever Page B's url is'); when you click on the correct link per row in the grid.
From Page B, you could use window.opener to reference Page A. So you can either refresh Page A by doing something like:
window.opener.location.reload();
or you could call whatever refresh type method that you define in Page A from Page B eg. window.opener.customMethod()
Related
I am currently working on creating functional tests using htmlunit.
On the webpage I am testing, there is an anchor which opens a page in a new tab when clicked. This anchor needs to be clicked to reveal additional check boxes and buttons.
If I wanted to save the page after clicking the anchor it would look something like this:
HtmlAnchor terms = tb.getFirstByXPath("//*[#id=\"terms_link\"]");
tb = terms.click();
However, the above code saves the webpage which is opened in the new tab as opposed to the web page in which the anchor was clicked.
Is there any way for me to save the page in which the anchor was clicked, or possibly save both html pages?
So after a bit of messing around I discovered that any actions which change the page are registered in the browser window regardless of whether or not you save them after an action.
In order to save the popup which occurs after clicking the an action just assign the resulting page to an HtmlPage object.
HtmlPage page = button.click
You can fetch the previous window and save it's modified contents with the following code. If you want to save the popup and the original page just save them to different object names.
page2 =(HtmlPage)(webClient.getWebWindows().get(0).getEnclosedPage());
This question is not about window handling or juggling of multiple browser windows, its about navigating through web pages of a web application within same window.
I have a situation where
1.I navigate as screen A->Screen x->Screen Y-> Screen B
2.I need to capture certain parameters on screen B from First login
3.I need to verify those parameters on screen B from second login
Here what i wish to do is to avoid the non important task of navigating through intermediate screens & jump directly to the concerned screen. Or directly capture the concerned parameter without bothering about UI.
Note- The URL on this application window is non editable manually.
Example-
Login->Jump to Screen B(First Login)
Login->Jump to Screen B(Second Login)
Firsts of all, is it possible at all??
Please help me with the suggestions of how to achieve this
Additional Detail-
URL to view a project named Selenium Test 275 (A specific web page in the application) is ->
http://172.24.186.71/esssfa/sfanew/UnitList.aspx?OID=12762&PID=12731&PRID=1&SecID=3
Edit:
I think I understand what your asking now. If you want to easily jump back a few pages, to that spefic screen B, I would use JavaScript.
(-1) will get the last page that was on your browsers stack. (-2) two pages, and (2) will then make the browser get two pages forward on the browser.
If you want to go back to Screen B try something like this after logging in.
driver.execute_script("window.history.go(-2)")
Then a variable can be used to store the data from the last login that you want to compare.
Possibly that the second window opens based on response from the server?
For e.g - the server could be returning a URI along with a session/security attribute(JSESSIONID, Authorization, etc) which is then appended with base URI to open up the new window. The session/security attribute explains the invalid session page message when you try to driver.get(URL) of the second page.
At the risk of being repetitive (rephrasing Vivek's question) - are you able to open the second screen in this way :
Login to the application (first screen) -> Open a fresh browser window -> Paste the (read-only) URL of the second screen and hit Enter -> Check second screen opens.
If yes, then it seems to be a case where it is not just simple GET request but possibly a request with some sort of Authorization code in the request headers.
Additional details might help answer your question : is it possible ?!
I am trying to get around a peculiarity with Wicket pages—I have a page containing an ajax tabbed panel, and would like to make it so the user can alter the URL so that the next time the page displays, the tab is the one specified in the URL.
Example:
The user would click on a link elsewhere in the system that would take them to: http://example.com/customer/edit?tab=summary
(This gets changed by wicket to include a version number:
http://example.com/customer/edit?1&tab=summary)
This would show the first tab as expected, but
If the user altered the url to http://example.com/customer/edit?1&tab=orders
Then the user would expect the orders tab to be displayed, but it isn't. It still displays the summary tab.
The problem is that the Page class is only ever given parameters on construction, so getPageParameters().get( "tab" ); would always be 'summary', unless the user alters that number that always gets appended to the params to one not already used. Then a new instance of the page is created with a fresh set of params.
Is there a way to make it so when the page is refreshed, it picks up the new url parameters of the request in onConfigure?
Try using the actual request parameters instead:
RequestCycle.get().getRequest().getQueryParameters()
I am building a project in GWT and the project requires navigation from one page to another when a button is clicked. How do I do this? Or should I simply write the entire code in the same class file? I know there has to be a way of navigation.
How should I achieve page navigation in GWT?
You should look at GWT Platform
With this library, you can define places. When the user clicks on a button, you just reveal a new place.
In addition, this framework allows you to handle the lifecycle of your GWT components and do some code splitting : page 1 and page 2 can be compiled in 2 different js so that you only load the one you need.
it is also a (and mainly) a MVP framework, like gwt-presenter.
You can do Page navigation through History mechanism of GWT. Here are the steps you should follow:
Add a history string to an iframe of your host page:
Register a ValueChangeHandler that will receive an event of history (page) change. Within this handler you need put a logic that displays the new page.
For example, History.addValueChangeHandler(object of subclass of HistoryHandler);
After doing this whenever you need to navigate to another page do the following: History.newItem("history string of your page to be displayed");
Hi firstly i want to mention that i am aware of ajax based application and reuse of same page.
The requirement here is that, i want to have two separate pages one for login and other for the main application. Now, this is not because i just want it, but because i have very different layouts in the two pages which i am comfortable to put together with html elements and css directly in the page and then putting divs to contain dynamic html for gwt to populate.
Even in case of myfaces i have not seen application with same page for login and the main app page.
Anyways, the problem i am facing is, lets say i have two pages
Login.html with a div : div id="login"
Main.html with a div: div id="main"
i have declared both of them in my welcome file list in web.xml
Now i start with Login page fill the "login" div with gwt widgets and on click of a button
i am using following jsni code to redirect to "/Main.html?gwt.codesvr=127.0.0.1:9997"
private native void gotoURL(String url) /-{
$wnd.location.href=url;
}-/;
and then trying to populate the "main" div. But the behaviour as i noticed is that the application call the entry point again and it doesnt find any element as "login" and gives NPE.
Is there a way to do this? also to get rid of the "?gwt.codesvr=127.0.0.1:9997"?
Thanks
First, you don't want to add the ?gwt.codesvr=... stuff - it's related only to hosted (debugging of gwt) mode. You could use a relative url (for example simply "Main.html"). But since you can only have a single entry point, you need to either split the app into two client modules (two separate apps actually) or dispatch in your entry point according to the url (whether you've landed on Login.html or Main.html)
Second, what I would do in this scenario is have an empty html with no layout except a single div for the dynamic content as the only html page of the app. Then I would use 2 UiBinders - one for the main page, and one for login, and use a hash suffix in the url (using GWT's history event and management, and hyperlink widgets) to know where I am. Maybe you should read more in GWT's documentation on history and stateful apps. Try http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsHistory.html#stateful