Hi,I am trying to create a UI automation tool for my product. I need to simulate a button click by a user. For that I want to invoke the onClick method of a button element. Is there any way to do it without actually clicking on that button? Can I create an event or just invoke the method in some way?
Subject: Simulating a button click
I’m not sure if this is what you are looking for, but I’ve used something like this before to trigger the click event for a button on the form in order to populate data based on a field value, using the onBlur event for the field:
[1] In the HTML tab of the Button Properties, enter the programmatic name for the button in the “Name” setting - for example: button1
[2] In the onBlur event for a field (or other object), use Javascript to invoke the click event for the button – for example: button1.click()
If I recall, I even hid the button on the form and still accessed it’s click event from the field’s onBlur event.
Randy
Subject: Simulating a button click
sorry if i haven’t understood what you want fully…But if you put the code behind said button in a script library… you could call said script library and run said code in your automatic process
Subject: RE: Simulating a button click
Q: sorry if i haven’t understood what you want fully…But if you put the code behind said button in a script library… you could call said script library and run said code in your automatic process
Ans:
I am working on an existing product where not all handler code is in script libraries. So I cannot call the handler routines. I have to somehow invoke the event handler itself.
Q: Please explain the trigger: if I understand you, no button will be physically clicked by user. What is the logical trigger that luanches your “simulated click” ?
Ans:
Right. I basically want to provide the user with a method like ClickButton(“Button_ID”) which will internally call the routine for OnClick event.
Subject: RE: Simulating a button click
you can use client side javascript document.getElementById(‘buttonID’).click() (if js applies to your context)
Otherwise you may need to use other alternatives, like putting the onclick codes on agents and trigger agents
Subject: Simulating a button click
Please explain the trigger: if I understand you, no button will be physically clicked by user. What is the logical trigger that luanches your “simulated click” ?