can Modules use the private variables?

Help
2008-07-30
2012-12-04
  • Nagarajan p

    Nagarajan p - 2008-07-30

    I need some clarification about private variables[local to the script]:
    1.Is there any possiblity to declare the variabls specific to the testcase?
    2.If so,how can define those and where?
    3.can modules uses those private variables while module present in the Testcase[script] and how?
    Pls have look this is my requirment:
    folder:Fixture
    ....
    ....
    folder:Modules
    project_module.py[contains n number of function say 10]
    ....

    folder:TestCases
    sample1.py
    sample2.py
    sample3.py
    .....
    .....
    now testcase "sample1.py" has lines below.

    def test():
        from Modules import project_module
        java_recorded_version = '1.6.0_01'

        if window('PCS-5000 Policy and Configuration Management'):
            ###############project_create module calling######################
            project_module.Create_project()

            doubleclick('Tree', '/PCS_Projects/PCS_UserDefinedProjects/SPDF123')
            select('Tree', '/PCS_Projects/PCS_UserDefinedProjects/SPDF123')
            rightclick('Tree', '/PCS_Projects/PCS_UserDefinedProjects/spdf4/PCS_AccessRules')
            select_menu('Assign Priority')

            if window('Assign Access Rules Priority'):
                select('List', 'PCS_AccessRuleDeniedMediaTypes.xml')
                click('UP')
                click('UP')
                click('UP')
                click('OK')
            close()

            if window('New Priority for Access Rules'):
                click('OK')
            close()

            ##################project_delete module calling########################
            project_module.Delete_project()   
        close()

    .................
    here i need to have a macro kind of approach "PROJECT_NAME" instead of "SPDF123" in the  corresponding place.
    PROJECT_NAME is a variable can have any value like "SPDF123","abcdfe123", "someproject123"...
    PROJECT_NAME is refered by the modules,if i am using the modules in any testcase it should pick up the vale for "PROJECT_NAME" from local [private variable file or specific to the testcase].

    Pls can any give me the idea how to proceed things...

     
    • Dakshinamurthy Karra

      1. You can use a global variable and set it at the beginning of the test. Then the variable will be available to all the module functions.

      2. Or define a new class with all the variables and initialize them in the test. Use a global variable to point to this object and use it in the modules. Or use a singleton pattern.

      All said and done, these test scripts are just python code. Whatever you can done with Python you can do here.

      HTH.

      -- KD

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks