3 Answers, 1 is accepted
We need a little more information before we can assist you.
- Where is this variable located? In your JavaScript code? In the test code?
- Do you value in the variable read and then put into the text box or the contents of the text box read and put into this variable?
- Are you trying to write test code that hooks into the button click event, or trying to use/set the variable after the button click is done?
Cody
Hi Cody,
Thanks for your reply.
- The variable is a global variable. No the code in not JavaScript.
- I read the value from variable and then assign it to the text box
- Yes, I am writing test code on the button click event.
-Arpita
I would like to better understand what it is you're trying to test. I ask because it is very unusual to want to hook into a button click event and act on it. The normal test sequence is to have the test click the button and then verify the correct response was returned by the web application. Would you mind giving me an overview of what it is you're trying to validate in this particular test case please? Once I understand what you're trying to accomplish I might be able to offer a better and easier way to accomplish it.
It is possible to hook into JavaScript events. This is documented here.
To set the text of an input text box you would use code like this:
string
text_to_set =
"Customer"
;
HtmlInputText textbox = Find.ById<HtmlInputText>(
"input_q"
);
textbox.Text = text_to_set;
Cody