Hi, I have a problem with my web automatic testing.
My problem is the web keep refreshing after execute ‘set text’ command. For your information, it caused by the auto-calculate function from the web (so every time I set the input of number, it will do calculate itself), maybe because there is an onchange function on that field (if yes, I wan t to delay the trigger after complete my input of number, because the trigger causes the input back to 0)
My concern is, when I do the recording, it was fine at all (the text just set first, then click anywhere, and following with the calculate function (which causes refresh the page)), but the input stay there. In case to execute that test case, the text just set in the same time with the calculate function (onchange was triggered too early), which causes the input cleared (back to 0).
I’ve tried using ‘wait’ or delay command, but it doesn’t work at all.
Can you help me how to solve it, or how to delay the trigger (onchange function)? I’ll appreciate all of your suggestion
First of all, thanks for your response
I’ve tried your solution, but I think that it still doesn’t work for my case
I want to said that my problem is not about how to trigger the onChange event, but the opposite, I want to delay/disable it because it makes my input on the fields are become empty. I will explain more about the what happened to my automation while the execution running below:
- I give an input of number (setText) to the field (which is have onChange event on there)
- in normal case, onChange event will called after I click another object
- but what happened to me, even when the field cleared, the onChange event already running (which is causes resetting my input of number (the input disappear/empty again))
Is there any solution to delay or disable onChange event from my test case? Or how can I do to prevent the onChange being triggered? Thanks before
I also wanna ask you about ‘unbind’ script, how can I know that the onChange events already removed when I executing my test case?
I strongly advise against modifying the event bindings. If you modify the AUT, any test you make is no longer testing the AUT. You are testing something else entirely.
If the user can’t do it, through normal page interactions, your test should not do it, either. You should strive to test what is there, not modify it so you can test something else instead.Here is a better approach_:_ test the outcome of user interactions, even if that includes page changes due to inputs becoming reset back to zero. If that is how the page works, that is what you should test.
If you believe the page is behaving improperly, tell the developers.
If you believe the page is untestable, tell the developers.
If you believe the developers could modify the page to aid testing, ask them to do that.
_If you modify the page, your results (passes and failures) are meaningless.
$( “input” ).unbind( “change”);
So if you want to remove change event from element with id “firstNumber” the command will be:
$( “#firstNumber” ).unbind( “change”);
Don’t forget the # at the begining of ID.
Please note that this is related to HTML itself and not Objects from ObjectRepository.