Forum Discussion

Sheetal's avatar
Sheetal
Occasional Contributor
9 years ago

How to perform cross reference of variables in script formation

@: How to perform cross reference of variables in script formation

 

Eg: I am automating Login page and in that in Unit1, I initialize Browser Script just to open the browser and go to the URL of the Login form and the value to the Login Object from Unit1 as:

//USEUNIT Login_Form

 

function Login()

{

  var browser;

  var url = "http://............./VPortal";

  var form, form1;

  Browsers.Item(btChrome).Run(url);

  page = Aliases.browser.page1921681224SsoLoginIvssoservi;

  form = page.formLoginform; 

 

  LoginObject("admin","admin");

  form.table.cell.Click(13, 6);

  form1 = Aliases.browser.page1921681224VportalMgtconsoleA.frameTopframe.link.Click();

 

  page.Wait();

  browser.page1921681224VportalMgtconsoleA.frameTopframe.link.Click();

  browser.page1921681224SsoLogoffIvssoserv.Wait();

        

}

In Unit2, I initialize login credentials and want to pass the values which is defined in Unit1 (Call by Value) to the textboxes (usename,password) initialized in Unit2 as:

function LoginObject(strUserName, strPassword)

{

 

  var textbox;

  var passwordBox;

 //Call Delay(20000);

 

 // textbox =Textbox("login");

 textbox = form.textboxUsername;

 textbox.Click();

 

   //textbox = Aliases.browser.page1921681224SsoLoginIvssoservi.formLoginform.textboxUsername.MappedName;

  textbox.SetText(strUserName);

  passwordBox = Login.form.passwordboxPassword;

//  passwordBox.SetText(strPassword);

 

How will I proceed to validate this scenario?

Help will be appreciated. If you have better example to do this please suggest also.

  • Sheetal's avatar
    Sheetal
    9 years ago

    Thanku Sir,

     

    I got the solution :- I pass the value to the function defined in another form as:

    LoginObject("admin","admin",form);

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I take it that you are talking about javascript. If I am correct with this, than this is a limitation of script engine itself but not of TestComplete.

    The only possible solution that I am aware of is to reorganize your test code so that it does not cross-reference script units.

    • Sheetal's avatar
      Sheetal
      Occasional Contributor

      Thanku Sir,

       

      I got the solution :- I pass the value to the function defined in another form as:

      LoginObject("admin","admin",form);