Hi,
I'm a newbie user of webtests. I'd like to find out how to read command line arguments inside my webtest generated code.
I'm recording webtests to test various webpages of an application server and would like to parameterize the root URL to these webpages. This is so that I could use the same webtest generated code to test different installations of the application server. The webpages have identical links except for the root URL which changes for each installation.
I have tried the following options and none of them worked:
I'm recording webtests to test various webpages of an application server and would like to parameterize the root URL to these webpages. This is so that I could use the same webtest generated code to test different installations of the application server. The webpages have identical links except for the root URL which changes for each installation.
I have tried the following options and none of them worked:
1. When I read command line arguments via System.Environment.GetCommandLineArgs(), it gives me the command line arguments for the Visual Studio process and not the ones I specified in the debug properties of the WebTest project.
2. I also executed the webtests from commandline using mstest, but it does not provide any option to pass specific command line arguments to the webtests.
3. I tried to manually add a 'main(string[] args)' method in the code & as expected that method is never called.
4. The 'Parameterize Web Server' option does not help because that would require me to manually add the root app server URL. However my scenario requires automated testing on newly provisioned appservers.
I'm hoping someone on this list would have come across a similar issue and found a resolution for it.
Thanks,
Amrita
4. The 'Parameterize Web Server' option does not help because that would require me to manually add the root app server URL. However my scenario requires automated testing on newly provisioned appservers.
I'm hoping someone on this list would have come across a similar issue and found a resolution for it.
Thanks,
Amrita

how to read command line arguments inside webtest generated code
MotJuste
User the parameterize web server option to create context parameters for each of the web servers. Then you can override the context parameter inside of a web test by using an environment variable. The name of the variable should be Test.<Context Parameter Name> So if you have a context parameter called WebServer1 with a value of http://qa_environment, but when you run the test from the command line you want to switch this to a different server. Right before you run the test, set an environment variable. So you would create a variable called Test.WebServer1 and set the value to somethine like, http://qa2_environment. Now when you run the test from the command line it will use the env variable instead of the value definied in the test.