Skip to main content

Hello. I'll be using UTAM for our Automation Framework.     For the setup, I did install the following:      1. Install UTAM  npm i utam      2/ INSTALL WDIO  npm init wdio    3. INSTALL UTAM WDIO SERVICE  npm i wdio-utam-service --save-dev    4. INSTALL DOTENV  npm install dotenv    4. INSTALL SALESFORCE PAGE OBJECTS  npm i salesforce-pageobjects    5. ADD UTAM AS DEV-DEPENDENCY  npm add --dev utam    6. ADD BUILD to package.json      "test:ui:compile": "utam -c utam.config.js",      "test:ui:generate:login": "node scripts/generate-login-url.js",      8. Add UTAM in wdio.config.js  require('dotenv').config();  const { UtamWdioService } = require('wdio-utam-service');    services: [          [              UtamWdioService,              {                  implicitTimeout: 0,                  injectionConfigs: ['salesforce-pageobjects/ui-global-components.config.json'],              },          ],      ]    -----------  However, whenever I run the test, it's still giving me either a reference error of "utam is not defined" or the import modules (e.g. import {DesktopLayoutContainer} from '/salesforce-pageobjects/dist/navex/pageObjects/desktopLayoutContainer' cannot be found'    I tried uninstalling and installing the node_modules and tried everything in https://www.geeksforgeeks.org/node-js/how-to-resolve-a-cannot-find-module-error-using-node-js/ and     What am I missing?   

1 réponse
  1. 21 janv., 11:40

    Hi @Aira Gutierrez

     

    The "UTAM not defined" and module import errors in 2026 typically stem from missing compiler generation steps or an incomplete link between your testing environment and the generated code.

    1. Resolve "UTAM is not defined"

    In 2026, the global utam object is not provided by default in standard Node.js scripts; it must be imported or generated via the compiler.

    • Ensure Compilation: Your wdio.config.js and tests depend on JavaScript files that are compiled from .utam.json files. Run the compiler command you added to your package.json:

    npm run test:ui:compile

     

    • Manual npx check: If the script fails, try running it directly to see specific error messages:

    npx utam -c utam.config.js

     

    • WDIO Global Hooks: Ensure your wdio.config.js properly exports the UtamWdioService. If you are trying to use utam in a test script, you must use the utam object injected by the service. In your test file, you typically don't import a global "utam"; you use the browser object or the injected loader: 

      javascript-

    // Instead of calling a global utam 

    const loader = browser.utam; // The service adds this to the browser object 

     

    2. Fix "Module not found" for Salesforce Page Objects

    The salesforce-pageobjects package contains JSON definitions that must be compiled into JavaScript before they can be imported. 

    • Correct Import Paths: In 2026, the standard package structure for salesforce-pageobjects does not always require the /dist/ path in the import string. Try importing from the package root: 

      javascript-

    // Use this 

    import { DesktopLayoutContainer } from 'salesforce-pageobjects/pageObjects/desktopLayoutContainer'; 

    // Instead of 

    import { DesktopLayoutContainer } from '/salesforce-pageobjects/dist/navex/...';

     

    • Update Package Version: Ensure you are using a version compatible with the current Salesforce release (Winter '26). Check for updates:

    npm install salesforce-pageobjects@latest --save-dev

     

    • Check utam.config.js: Ensure your configuration file explicitly lists salesforce-pageobjects in the injectionConfigs. An empty or missing configuration will prevent the generator from finding the Salesforce definitions. 

    3. Verify WebDriverIO Configuration

    If you recently upgraded to WebDriverIO v8 or v9 (standard in 2026), ensure your wdio.conf.js is using the newer object-based service definition. 

    • Service Configuration: Ensure the UtamWdioService is properly imported and added: 

      javascript-

    const { UtamWdioService } = require('wdio-utam-service'); 

    exports.config = { 

        // ... 

        services: [ 

            [UtamWdioService, { 

                implicitTimeout: 0, 

                injectionConfigs: ['salesforce-pageobjects/ui-global-components.config.json'] 

            }] 

        ], 

    };

     

    Final Troubleshooting Step: If imports still fail, check your node_modules folder manually to confirm the file path salesforce-pageobjects/pageObjects/desktopLayoutContainer.js exists. If only .json files exist there, the package was not compiled correctly.

0/9000