Forum Discussion

walvarez's avatar
walvarez
Occasional Contributor
26 days ago

Project Level config file

Hi,
Is there a way to make the test complete project to read a single file (json or csv) that controls all parameter/variable values?

For example, we have different environment to run the test. So we are wondering if we can control the environment it will run in a single file instead of adding conditions in namemapping for the URL?

 

9 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Yes you can. 

    In my project, I have the mapped object 'browser' which uses a project variable, it's default value is "chrome",

    and the main page uses conditional expression, based on the environment that I use,

    I use Storages.INI method to read my configuration file, which consists of a database string, browser (Chrome or Edge), and environment (either http://als.nightly.nonauth..., http://als.uat.nonauth..., http://als.reg.nonauth..., http://als.ps.nonauth..., etc).

    I've defined a singleton class (singleton is a design pattern, where we can create only one instance of a class and that instance can be accessed globally) to read the .ini file. This is called at the beginning of all my JavaScript files, to setup up the variables.

    Alternatively, you can also use TestComplete Command Line with /PrjVar parameter, to pass in your environment value

  • walvarez's avatar
    walvarez
    Occasional Contributor

    Hi rraghvani,

    Thanks for your reply.
    So meaning, There's no fastest way to add/control the URLs inside the namemapping than to add a condition to all main pages in the mapping?

    Because that is exactly what I have shown in the screenshot. (the one posted above is just in edit mode)

    here's an example of our current process:

    we add a condition for expected URL of the environment it should run and control the environment in a parameter. But since our project is getting bigger, the update process takes a lot of time. We were updating like 20+ sub modules in the project with 30+ pages in each namemapping of that modules whenever there's a new environment that it should run.

    • rraghvani's avatar
      rraghvani
      Champion Level 3

      You seem to have a lot of pages beneath browser? What is different between the pages?

      It's vital to get the mapped object structured correctly.

      • walvarez's avatar
        walvarez
        Occasional Contributor

        Yeah. there's a lot of pages under browser. It was auto created by TC upon point-and-fix by the previous maker. And he did not revise the namemapping or even the xpaths of every objects.

        example:
        http://baseURL.com//page1.html
        http://baseURL.com//page2.html
        http://baseURL.com//page3.html
        http://baseURL.com//page4.html
        http://baseURL.com//page5.html

        and so on. so in every changes in the URL, it creates a new page under browser.
        but now, since the baseURL would change for every new environment, we need to add condition to all pages for new baseURLs.