I am working on creating a pop-up in JSF for my project. The popup will be used for Country/State/City look-up.
The requirements are as follows:
It should be an overlay panel and not a new browser window
This is easier. I have multiple options
jQuery dialog
Some JSF library popup (ex. richfaces dialog)
The pop-up should be a separate page (a different JSP/XHTML) so the pop-up code won't get copied in a lot of pages
This is also easy. I could make a separate JSP and use some include tag to include this jsp where ever the pop-up is required.
The pop-up JSP should be able to have form with controls that may result in post-back events within the pop-up. Like the popup may have search functionality. So there may be an in put textbox, a button along with a datatable on the pop-up. When the search button is clicked,
some action needs to be executed to load the contents of the datatable, so the form (on the pop-up) will be submitted. This should not result in the pop-up being closed.
I am stuck up with this last requirement. If when the form (on pop-up) is submitted, the pop-up should not close, then this action should be asynchronous (AJAX). But the AJAX is not used in all the actions in my project. So If I need to solve this problem using AJAX, the AJAX script should be generic enough which won't require all the pop-up JSP's to re-write.
There might be a requirement to exchange data between the host page and the pop-up JSP.
May be this can be solved with some JS script. Am I correct ?
I need help with point# 3 and 4. In general if you are aware of any existing library to solve the problem, it would be great, but even if you could help with some directions, it would be appreciated.
Thanks in advance.
Related
I'm working on a some automation work, as per my requirement I need to click on Chrome Physical buttons like left nav, right nav, bookmarks, menu etc. I can do with shortcuts but my requirement is to click on browser buttons. Any ideas would be helpful. Thanks in advance.
As per your question you want to click on Chrome Physical buttons like left navigation, right navigation, bookmarks, menu etc.
But if you look into the documentation in Selenium Home Page it clearly mentions that :
The entire suite of tools provided by Selenium results in a rich set of testing functions specifically geared to the needs of testing of web applications. These operations allow many options for locating UI elements and comparing expected test results against actual application behavior.
So factually Selenium by design interacts with the HTML DOM and the WebElements located in the DOM Tree
Now the desired controls e.g. left navigation, right navigation, bookmarks, menu are out of the DOM. Hence you cannot mock the click on those controls.
However all the Selenium Language Binding Art provides a handfull of methods to achieve the same result. Here are a few from the Selenium Python Binding Art :
Maximize : To maximize the browser window.
driver.maximize_window()
Minimize : To minimize the browser window.
driver.minimize_window()
Close : To close the browser window.
driver.close()
Quit : To close the browser window gracefully.
driver.quit()
Refresh : To refresh the url.
driver.refresh()
Forward : To move forward.
driver.forward()
Back : To move backwards.
driver.back()
And of-coarse Get : To invoke an url.
driver.get('http://google.com/')
There are functions for this that is built-in:
driver.forward()
driver.back()
https://selenium-python.readthedocs.io/navigating.html#navigation-history-and-location
It doesn't appear that selenium can interact with the Bookmark, but let me check some more.
This can't be done with selenium webdriver and I think also not with the standalone selenium server. Selenium only allows to interact with the DOM.
The only way to achieve what you want to do is to use an automation tool that actually runs directly in the OS that you use. Java can be used to write such a program.
I would however recommend to not go this route. Instead try to convince whoever is responsible for your requirements to re-think and allow to use other means of achieving back and forward actions.
I need to open a browser with URL and then wait till person clicks a special button. And if it happens, return true. Can I implement it with java tools or should I use javascript?
You should use JavaScript. Java is a Server side language, so all processing of Java code will be completed before the user has the chance to interact with the page. JavaScript (traditionally) works on the client-side and is commonly used to capture user interactions with the browser.
yes, Java Script or any frame work that builds on Java script like Jquery works for you. If understands you correctly,
create Hyper link
Browse the page that you needed
Place HTML button on the page, write onClick logic on that button to return true.
Is it normal that the default place is automatically in the browser history at the first position? When I initially call my application I have the possibility to use the back button in my browser. Then the browser jumps to my default page which is my error page. Is this the normal behavior?
The history is handled by the browser. You have no chance to change it.
Maybe you can change your application and use a dialogbox to show your errors, so no entry will be down in the browser history.
Read the gwt documentation about history.
http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsHistory.html
Look at:
History.addValueChangeHandler(new ValueChangeHandler.....
Then you need to set history tokens in each view.
With this you can change the browser back button behaviour and how you navigate in the app.
I'm working with the eclipse SWT toolkit, and I'm trying to use it to create a browser window that only passes mouse clicks to the underlying document conditionally (I want to stop Flash and Javascript in the page from getting clicks). I'd like some way of doing one of:
Examining mouse events as they come in, and only passing them on to other listeners based on conditions I specify.
Removing all listeners from a window, and only putting back the ones I want.
Are either of these possible?
Browser, like other SWT components, have addMouseListener method. So you could implement your own listener a pass only which one you want.
see javadoc of browser
Edit
According to your request, there could be two possible ways to do it.
First, you could use listening of events from JavaScript in browser (there is no way to avoid JavaScript if you work with html pages). If you know that you will have Mozilla browser render core (you have to install XUL Runner), you could use JavaXPCOM, but that's big unknown for me.
snippet - listen for DOM mousedown events with javascript
Second, you can call Java functions from JavaScript (again, handle onclick event, and then decide on Java, if you don't want to use JavaScript for it).
snippet - call Java from JavaScript
But frankly both ways are more ugly-er that proposed way by pure JavaScript.
Hi I am building div content with AJAX call, but when I make call to any page from loaded page, if there is any exception the content loaded from AJAX call is not there in previous page. Is there any way to stop happening that?
Ajax vs Back button
If I understand well you are pressing the browser back button.
If you don't manage the history of the browser, it will break Ajax. The browser simply goes to the last location loaded, no ajax involved. If you did 3 ajax calls/loads in the last page, back button will ignore this because it's just javascript in the page and it will go back... very back.
What you can do
There are things you can do to preserve the back semantics in your ajax app but I don't know how you do it with jquery. Maybe it has tools for that. I know something about GWT that has history managing. But it's another framework...
See the History plugin. Highly recommended for this purpose.