naplespoet
14 years agoNew Contributor
Function creation with C#script
I'm new to c# and I used to use winrunner before HP days and one thing I used in functions were the parameters to push in so that when the function ran it would set the text value as to what I passed into the function call.
essentially I need to find out first how that part of the function is created and then how to then, when i pass the function in that value gets set in my text field. I know im missing the value set in the function name , not sure how to set that up and how the text field knows that even though these are declared during this test run I only want to use what I passed in and not actually hardcode what User1/Pass1 into the text field expression. Please help. Im reading as much as I can but cant seem to find a good example.
function Login ()
{
essentially I need to find out first how that part of the function is created and then how to then, when i pass the function in that value gets set in my text field. I know im missing the value set in the function name , not sure how to set that up and how the text field knows that even though these are declared during this test run I only want to use what I passed in and not actually hardcode what User1/Pass1 into the text field expression. Please help. Im reading as much as I can but cant seem to find a good example.
function Login ()
{
var User1;
var Pass1;
var Pass2;
User1 = testuser // username for textbox
Pass1 = testpass // password for textbox
Pass2 = testpass01 // password for textbox
form = page["table"]["cellSmall"]["table"]["formLogin"];
textbox = form["cellSmall"]["textboxUserName"];
textbox["Click"](16, 11);
textbox["Text"] = "testuser"; // this would need to express value of what parameter I passed in grabbing it to declared values
form["cell"]["passwordboxPassword"]["Text"] = "testpass"; // this would need to express value of what parameter I passed in grabbing it to declared values