Forum Discussion

vonbailey's avatar
vonbailey
Occasional Contributor
15 years ago

Changing the Target Server through Scripts

Is it possible to change the Target Server through scripts?  I have three different domains (QA, Staging & Production) and I need to run the same testing on all three.  Currently I have to record a task for each environment and I would like to simply run a script in which I can choose the environment I wish to run the task in via a menu using the same task which simply points to the correct environment.

6 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Von,



    Doesn't the TargetServer property of the Task work for you (see the "Changing the Tested Server" help topic for more details)?
  • vonbailey's avatar
    vonbailey
    Occasional Contributor
    Sorry, my bad.  I should have checked the help data before coming here.  Thanks for pointing me in the right direction.



    von
  • Hi

    I am facing the same issue in TC 8.

    I have followed the instruction at "Changing the Tested Server" help topic, changed target server in task editor, checked "Correct Host Field" at the test element. But still not working. I trap the traffic using fiddlers and found that it still referring to my original target server.



    I have upload my project in my previous message. You can get it from there.



    Please advice. Thank you
  • Hi

    I also tried to do this with scripting, but also hit error








    Sub AAA

          TargetServer = "vsmrnd"

          

          Set task = LoadTesting.HTTPTask("ViewPayslipTask")

          task.TargetServer = TargetServer

          

          Set user = LoadTesting.CreateVirtualUser("User1")

          user.Station = LoadTesting.Stations(0)                              

          user.Task = task

          

          Set testInstance = LoadTesting.CreateTestInstance("Test1")





          user.TestInstance = testInstance

             

          testInstance.Run "Test1"





    End Sub
  • OK, I found my mistake. It is because my target server is not point to the "right" one when recording. That why when I change it the changes not apply to the rest