Forum Discussion

blbdt36's avatar
blbdt36
Contributor
9 years ago
Solved

Using a variable in the code is not working the same as putting in the exact webpage

I have an input file that holds all the data I need for my tests.  This allows the user to update as needed and still be able to run the tests.  I also want to be able to use this file to select the environment to run the tests.  Since it is a webpage, I figured I could just replace the address with the variable and it would work the same.  I am not finding this to be the case.  The first problem I am running into is that it isn't recognizing the .Wait functionality that I absolutely need.

 

These fail

var testenvironment = getTestCase("environment").Entered;
testenvironment = "Aliases.browser." + testenvironment;

testenvironment.Wait(10000);

 

var testenvironment = getTestCase("environment").Entered;

Aliases.browser.testenvironment.Wait(10000);

 

 

But this works

Aliases.browser.NameMappedWebPageCom.Wait(10000);

 

 

I don't understand why it fails.  If I can't get this simple statement to work, I don't want to waste my time changing all of my scripts, but being able to just feed in the environment would be fantastic

 

Thanks

  • What you have in the testenvironment variable is a string and you need it to be an object. 

     

    In vbscript I would use

     

    set testenvironment = "Aliases.browser." + testenvironment

     

    or maybe

     

    testenvironment = eval("Aliases.browser." + testenvironment)

2 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    What you have in the testenvironment variable is a string and you need it to be an object. 

     

    In vbscript I would use

     

    set testenvironment = "Aliases.browser." + testenvironment

     

    or maybe

     

    testenvironment = eval("Aliases.browser." + testenvironment)

    • blbdt36's avatar
      blbdt36
      Contributor

      Thanks for the response!

      That's what my developer said, too.  

       

      For JScript, it looks like this  

      Aliases.browser[testenvironment].Wait(1000);