Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.DEFAULTS = exports.getPrototype = void 0;
  7. const path_1 = __importDefault(require("path"));
  8. const logger_1 = __importDefault(require("@wdio/logger"));
  9. const utils_1 = require("@wdio/utils");
  10. const config_1 = require("@wdio/config");
  11. const constants_1 = require("./constants");
  12. Object.defineProperty(exports, "DEFAULTS", { enumerable: true, get: function () { return constants_1.DEFAULTS; } });
  13. const utils_2 = require("./utils");
  14. Object.defineProperty(exports, "getPrototype", { enumerable: true, get: function () { return utils_2.getPrototype; } });
  15. const log = logger_1.default('webdriver');
  16. class WebDriver {
  17. static async newSession(options = {}, modifier, userPrototype = {}, customCommandWrapper) {
  18. const params = config_1.validateConfig(constants_1.DEFAULTS, options);
  19. if (!options.logLevels || !options.logLevels.webdriver) {
  20. logger_1.default.setLevel('webdriver', params.logLevel);
  21. }
  22. if (params.outputDir && !process.env.WDIO_LOG_PATH) {
  23. process.env.WDIO_LOG_PATH = path_1.default.join(params.outputDir, 'wdio.log');
  24. }
  25. log.info('Initiate new session using the WebDriver protocol');
  26. const { directConnectProtocol, directConnectHost, directConnectPort, directConnectPath } = params;
  27. if (directConnectProtocol && directConnectHost && directConnectPort && (directConnectPath || directConnectPath === '')) {
  28. log.info('Found direct connect information in new session response. ' +
  29. `Will connect to server at ${directConnectProtocol}://${directConnectHost}:${directConnectPort}/${directConnectPath}`);
  30. params.protocol = directConnectProtocol;
  31. params.hostname = directConnectHost;
  32. params.port = directConnectPort;
  33. params.path = directConnectPath;
  34. }
  35. const { sessionId, capabilities } = await utils_2.startWebDriverSession(params);
  36. const environment = utils_1.sessionEnvironmentDetector({ capabilities, requestedCapabilities: params.requestedCapabilities });
  37. const environmentPrototype = utils_2.getEnvironmentVars(environment);
  38. const protocolCommands = utils_2.getPrototype(environment);
  39. const prototype = { ...protocolCommands, ...environmentPrototype, ...userPrototype };
  40. const monad = utils_1.webdriverMonad(params, modifier, prototype);
  41. return monad(sessionId, customCommandWrapper);
  42. }
  43. static attachToSession(options, modifier, userPrototype = {}, commandWrapper) {
  44. if (!options || typeof options.sessionId !== 'string') {
  45. throw new Error('sessionId is required to attach to existing session');
  46. }
  47. if (options.logLevel !== undefined) {
  48. logger_1.default.setLevel('webdriver', options.logLevel);
  49. }
  50. options.capabilities = options.capabilities || {};
  51. options.isW3C = options.isW3C === false ? false : true;
  52. const environmentPrototype = utils_2.getEnvironmentVars(options);
  53. const protocolCommands = utils_2.getPrototype(options);
  54. const prototype = { ...protocolCommands, ...environmentPrototype, ...userPrototype };
  55. const monad = utils_1.webdriverMonad(options, modifier, prototype);
  56. return monad(options.sessionId, commandWrapper);
  57. }
  58. static async reloadSession(instance) {
  59. const params = {
  60. ...instance.options,
  61. capabilities: instance.requestedCapabilities
  62. };
  63. const { sessionId, capabilities } = await utils_2.startWebDriverSession(params);
  64. instance.sessionId = sessionId;
  65. instance.capabilities = capabilities;
  66. return sessionId;
  67. }
  68. static get WebDriver() {
  69. return WebDriver;
  70. }
  71. }
  72. exports.default = WebDriver;