Click button in Htmlunit - java

I am writing a program in Htmunit where I need to fill in two fields with text, but to get to these fields I need to click on a button to allow for the fields to appear on the screen. I cannot create a new button and click it because that will return a new "page" which I do not want. What other way is there to click on a button without creating a new page, but rather stay on the same page. For reference, I am using this website. The page I need to do this on is the page after the terms acceptance page. I need to click on "foreclosure search", then enter information to the fields.

Related

Saving multiple pages simultaneously in htmlunit

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());

Jsf form Print preview

I have a JSF form of view *.jspx page. The form has around 20 fields. I have a print preview button, that would open a new browser window and show print preview of this form, making all the form content as read only.
I have done a bit of workaround like setting a boolean flag in Managed bean as showprintPreview. This approach has almost done the job by showing all the fields in readonly and buttons as disabled mode.
But, I don't want to change the backing bean object.
I'd like to show the print preview with css or javascript for a jsf form.
UPDATE:
I have tried another way by using onclick on print preview button that would call predefined, window.print() js function. But its displaying all the buttons as well. I would like to hide buttons like submit, back etc in print preview and show all the input fields like text, textarea etc.
I would reuse part of page wich you want to print. Create new page only with this reusable part. then on button action open this new page in new window (target="_blank") in print preview you mentioned.

GWT- PopupPanel with search?

I am looking for a way to create a popup dialog box when a user double clicks a textinput field that will contain a scroll-able list (from database table) where the user can select a field, hit ok, and have it placed into the textbox when popup closes.
The other major requirement is to have a filter/ or search field in the popup to aid the user in finding the correct option to select from quicker.
What is the best way to implement this?
Modification to gwt's popup panel? maybe a JOptionPane? are there any simple solutions already designed for free commercial use?
You could implement this with a com.google.gwt.user.client.ui.PopupPanel. You can make a PopupPanel that contains a ListBox with your data from the database, along with a OK button. When a user selects a value and hits OK, you should utilize an EventBus along with a custom Event that will pass the value to the field on the page. The page will have an event handler that will catch the event and put it into the field.
Another option is to use a com.google.gwt.user.client.ui.SuggestBox. It is a box that autocompletes / suggests values as you type, kind of like the Youtube search bar.
I can offer more resources to help you accomplish this, if you'd like.

how to load a popup with data and return selected option to the original form

I have a form where user can select an image out of list of images.
I would like to have a button "Select image".
When button is pressed there should be pop-up or overlay with the list of available images.
When user selects an image, the id of image should be returned to the original form.
I totally have no clue how to do this.
Any help would be appreciated.
This should be pretty simple:
On click of "Select", show a div (mark it with high zindex to have popup behaviour or use jQuery dialog)
On this popup add all your images (whether you would like to add the images in html table or use div is upto you)
Add listener to your images (if all your images have a single class then somehting like :
jQuery('.imgclass').click)
When user close this div, use the id which you will capture in step 3.

How to retain the data while clicking on the cancel button in page.?

I have a Employee add page which has lot of information to be filled. So, user requested 'copy info' functionality from other Employee..On top of the add page i have 'copy info' button which in turn redirects to another page which lists all employees. from that user select one of the employee and whose informations are copied to this add page. untill this it is fine.
If the user filled some information in add page and clicks on 'copy info' button and in the second page if he clicks on cancel, it should comes back to add bage with information what he was filled. I am not able to hold the filled information. Any idea to have the filled information other than storing it in session?
If code is reqired to undestand better will be posted.let me know.
thanks.
Create an object, which fields are the form fields, and pass it down to your page. This object will not be destroyed as the parent class still holds the pointer.

Categories

Resources