1
votes

I have an "input"-WebElement that has a "onkeyup" AJAX call. (It's a order-amount field)

I want to check the error message that checks the amount entered against what's actually in stock with Selenium Webdriver in Java.

However, I think because of the "onkeyup" the input field always resets back to the defaul value "1" after the sendkeys from Webdriver. I tried with and without clear and also tried to check the field was empty after the clear.

Any idea how the field value reset can be prevent in spite of the "onkeyup"?

1
Can u elaborate a bit here...what happens when you enter data manually, lets assume you enter 10 (which is 2 keys..am assuming that is where the problem is..)? When is default value set by the application? - niharika_neo
Onkeyup there's a A4J.AJAX.Submit. When I do things manually everything works just fine. However, with sendkeys the input field always gets reset to its initial value of "1" (I entered for example "8", "88" or "888"). The amount has to be higher than stock that's left of course. I suspect it might be the click that's following in my testscript. - Ben Schnitzel
I tried with Thread.sleep (really my last resort, I try to avoid it as much as possible) - doesn't work either. This is really strange behaviour! - Ben Schnitzel
can you share a url to look at the behavior? - niharika_neo

1 Answers

0
votes

I found the solution here:

https://groups.google.com/forum/?fromgroups=#!topic/webdriver/UiV08YgUxSI

For me the Keys.BACK_SPACE did the trick

Doesn't work with WebElement.clear() and doesn't work without the clear() or BACK_SPACE.