PDA

View Full Version : How run value validation for listbox in htmlunit?



Yuka
25 Apr 2011, 11:56 AM
Hi!

I try to use htmlunit for performance testing and have problem with subj (How run value validation for listbox in htmlunit?).

We have listbox (user can type value or / and select value from dropdown list). I can set value (from buffer) to this field, but this value doesn't validated - like I post wrong value.

I can reproduce the same behavior at browser:
1. open form
2. select some value from listbox
3. copy value
4. reopen page
5. past value to listbox field, go to next field
6. oops! this value doesn't validated - like I posted wrong one.
7. I can click to dropdown icon and this value will be validated.
I can't submit form without this validation.

I tried (at htmlunit):
* type one after one symbol or whole value at one
* set focus at listbox and wait for some time
'page.setFocusedElement(userEditElement);' or 'userEditElement.focus();'

* explicitly wait for js:
'webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.waitForBackgroundJavaScript(waitForBackgroundJavaScriptTime);
webClient.waitForBackgroundJavaScriptStartingBefore(waitForBackgroundJavaScriptTime);'

* go to next element and come back:
page.tabToNextElement();
Utils.sleep(400);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.waitForBackgroundJavaScript(waitForBackgroundJavaScriptTime);
webClient.waitForBackgroundJavaScriptStartingBefore(waitForBackgroundJavaScriptTime);
page.tabToPreviousElement();
Utils.sleep(400);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.waitForBackgroundJavaScript(waitForBackgroundJavaScriptTime);
webClient.waitForBackgroundJavaScriptStartingBefore(waitForBackgroundJavaScriptTime);

* run mouseUp, mouseDown, mouseOver at listbox

But, it doesn't work!

Do you know, how can I validate pasted value?

Thank you.

Yuka
27 Apr 2011, 5:12 AM
Can anybody post the link or describe how works validation of listbox / dropdown, please?

As far as I understand, to work with this field I can:
* (or) find some way to post data with executing validation after it.
I tried to use 'type' method of htmlunit and simple set 'value' property (+ see previous post) - but it didn't execute validation.
* (or) run some js method to start validation manually.
But I don't know what method have I execute...
* (or) validate page manually.
And again I don't know that I have to do with this element to validate data manually.
I can remove validation icons and messages from page, but it's not enough...

Unfortunately, ext js is black box for me...