Ask a Question

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

SOLVED
blbdt36
Contributor

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

2 REPLIES 2
Marsha_R
Community Hero

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)


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

Thanks for the response!

That's what my developer said, too.  

 

For JScript, it looks like this  

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

cancel
Showing results for 
Search instead for 
Did you mean: