量角器oracledb连接失败,出现NoSuchSessionError

时间:2018-11-01 17:00:33

标签: oracle protractor node-oracledb

我正在尝试进行数据驱动的量角器测试。第一件事是对oracle表运行查询以返回一组数据。然后遍历该数据,调用其他规范。 oracle连接失败,没有错误。所以我在调试模式下运行,却遇到了这个未捕获的异常:

NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
    at session_.flow_.promise (C:\Users\me\repos\wbhtml5\designer-e2e\node_modules\selenium-webdriver\lib\webdriver.js:847:16)
    at new Promise (<anonymous>)
    at SimpleScheduler.promise (C:\Users\me\repos\wbhtml5\designer-e2e\node_modules\selenium-webdriver\lib\promise.js:2242:12)
    at promise.finally (C:\Users\me\repos\wbhtml5\designer-e2e\node_modules\selenium-webdriver\lib\webdriver.js:846:34)
    at promise.then.error (C:\Users\me\repos\wbhtml5\designer-e2e\node_modules\selenium-webdriver\lib\promise.js:1684:12)

我不知道为什么会出现Promise错误或会话错误。我没有使用浏览器/网络驱动程序,但只想连接到oracle。

这是我的测试规范,表明量角器正在运行,以建立连接:

test.js

import VerifyDesignSpec from '../../specs/verify-design.e2e-spec';
import dbms = require('../../database');

// Connect to oracle and get list of parts
dbms.getProductFolderPartsCallback(dbms.PFPartKind.Switcher, dbms.PFPartStatus.Production, runProductFolderCallback);

// Callback function to loop over list of parts
function runProductFolderCallback(err, result) {
  const partsToTest = JSON.parse(result);
  partsToTest.forEach(part => {
    VerifyDesignSpec.ProductFolderDesignVerification(part, null);
  });
}

这是database.js

import Common from './common';
import credentials = require('./credentials');
import oracledb = require('oracledb');

export function getProductFolderPartsCallback(partType: PFPartKind, partStatus: PFPartStatus, callback) {
  const dbms = oracledb;
  dbms.fetchAsString = [ oracledb.CLOB ];

  const cred = credentials.getCredential(credentials.TestCredentialKind.SomeDB);

  dbms.getConnection({
    user: cred.Userid,
    password: cred.Password,
    connectString: cred.ConnectionString
  },
    function (connErr, conn) {
      if (connErr) {
        Common.error(`getProductFolderParts: connection error: ${connErr}.`, true);
        return callback(connErr);
      }

      const sqlCmd = 'SELECT PART_JSON FROM WEBENCHDB.ODT_PRODUCT_FOLDER_PARTS';

      conn.execute(sqlCmd, function (queryErr, result) {
        if (queryErr) {
          Common.error(`getProductFolderParts: query error: ${queryErr}`, true);
          closeConnection(conn);
          return callback(queryErr);
        }

        let resultJSON = '';

        (result.rows as any[]).forEach(row => {
          if (resultJSON.length === 0) {
            resultJSON = `[ ${row[0]}`;
          } else {
            resultJSON = resultJSON + `, ${row}`;
          }
        });

        resultJSON = resultJSON + ']';

        closeConnection(conn);

        return callback(null, resultJSON);
      }
      );
    });
}

function closeConnection(conn) {
  conn.close(function (err) {
    if (err) {
      Common.error(`getProductFolderParts: connection close error: ${err}`, true);
    } else {
      Common.info(`getProductFolderParts: connection closed`, true);
    }
  });
}

0 个答案:

没有答案