Forum Discussion

sd's avatar
sd
Occasional Contributor
7 years ago
Solved

How I can run same test case into different test environments?

For example I want to automate login and logout function for user. I want to run same automated keyword test into Test environment A and Test environment B.  Somehow for username and password fields, the object is not recognize in Test environment B because I have recorded test into Test environment A. Please help. How I can use only one environment to automate all my test cases and run them successfully into all other test environments.

  • We do the same... we have multiple environments for testing our one application.  What we've done is the following:

    1) All NameMapping for pages "wildcard" the portion of the URL that changes between environments.  For example, environment A may have http://myServerA/FolderA/page.aspx and Environment B may have http://myServerB/FolderA/page.aspx.  So, in our name mapping, when we map the page, we map the URL as */page.aspx.

    2) We have a project level variable called environment which we set at the start of our test run based upon the data we pass in via our automation framework (SQL backend contains data to indicate environment).  We set that variable to our base URL for the environment. 

    3) When we have our code launch the application, we use the Browser.Run() command and pass to "Run" a code expression that concatenates the environment base URL with the primary landing page of the application.

     

    The over all effect is that, by configuring our SQL properly, we can say, "Run test cases against Environment A" or "Run test cases against Environment B" and the combination of the variable, the mapping, our launch code and the data from SQL and we have a dynamic set of tests that we can run against any environment we wish.

5 Replies

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      We do the same... we have multiple environments for testing our one application.  What we've done is the following:

      1) All NameMapping for pages "wildcard" the portion of the URL that changes between environments.  For example, environment A may have http://myServerA/FolderA/page.aspx and Environment B may have http://myServerB/FolderA/page.aspx.  So, in our name mapping, when we map the page, we map the URL as */page.aspx.

      2) We have a project level variable called environment which we set at the start of our test run based upon the data we pass in via our automation framework (SQL backend contains data to indicate environment).  We set that variable to our base URL for the environment. 

      3) When we have our code launch the application, we use the Browser.Run() command and pass to "Run" a code expression that concatenates the environment base URL with the primary landing page of the application.

       

      The over all effect is that, by configuring our SQL properly, we can say, "Run test cases against Environment A" or "Run test cases against Environment B" and the combination of the variable, the mapping, our launch code and the data from SQL and we have a dynamic set of tests that we can run against any environment we wish.

      • sd's avatar
        sd
        Occasional Contributor

        Thanks a lot for your reply Robert. Does that means all pages in the application we have to name map to make them work into different environments?

        For example I have below four urls

        home page:https://myServerA/FolderA/page.aspx 

        login page:https://myServerA/FolderA.lginaction.do

        after login: https://myServerA/FolderA.profile.ftl

        shopping cart: https://myServerA/FolderA.shoppingcart.do

         

        From all above urls only the last part is changing after wording FolderA. The beginning stays same for all. So do I need to name map all these pages using wildcard for different environments? Again. Thanks so much for your reply.

  • sd's avatar
    sd
    Occasional Contributor

    Thanks Robert for your help. I tried it and it worked.