Sharing the Scripted Object Map

Sharing the Scripted Object Map

Often, we are asked whether the scripted object map file can be shared between multiple test suites by moving the names.py file to a global scripts folder (the extension of names varies depending on the scripting language in use).

For technical reasons, the default location of the names.py file, which is in the C:\suite\shared\scripts subdirectory of a test suite (e.g., on Windows), cannot be changed. Instead, it is possible to include other files in the names.py file which in turn can be used to share a Script-based Object Map between test suites. This is explained with the help of an example below:

Each script you want to include in your Script-based Object Map, in order to share it between multiple suites, should be in a global scripts folder. Assuming there is a script file named common.py in a global scripts folder, simply include the global script files at the beginning of the Script-based Object Map as shown below:

Contents of the names.py file:

# encoding: UTF-8
from objectmaphelper import *
from common import *

Contents of the common.py file:

# encoding: UTF-8
from objectmaphelper import *
address_Book_MainWindow = {"type": "MainWindow", "unnamed": 1, "visible": 1, "windowTitle": "Address Book"}
address_Book_File_QToolBar = {"type": "QToolBar", "unnamed": 1, "visible": 1, "window": address_Book_MainWindow, "windowTitle": "File"}
address_Book_File_QTableWidget = {"aboveWidget": address_Book_File_QToolBar, "type": "QTableWidget", "unnamed": 1, "visible": 1, "window": address_Book_MainWindow}

Contents of the test.py file:

import names
def main():
    startApplication("addressbook")
    ...

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*