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 5.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. "use strict";
  2. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  3. if (k2 === undefined) k2 = k;
  4. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  5. }) : (function(o, m, k, k2) {
  6. if (k2 === undefined) k2 = k;
  7. o[k2] = m[k];
  8. }));
  9. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  10. Object.defineProperty(o, "default", { enumerable: true, value: v });
  11. }) : function(o, v) {
  12. o["default"] = v;
  13. });
  14. var __importStar = (this && this.__importStar) || function (mod) {
  15. if (mod && mod.__esModule) return mod;
  16. var result = {};
  17. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  18. __setModuleDefault(result, mod);
  19. return result;
  20. };
  21. var __importDefault = (this && this.__importDefault) || function (mod) {
  22. return (mod && mod.__esModule) ? mod : { "default": mod };
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. exports.SevereServiceError = exports.multiremote = exports.attach = exports.remote = void 0;
  26. const logger_1 = __importDefault(require("@wdio/logger"));
  27. const webdriver_1 = __importStar(require("webdriver"));
  28. const config_1 = require("@wdio/config");
  29. const utils_1 = require("@wdio/utils");
  30. const multiremote_1 = __importDefault(require("./multiremote"));
  31. const SevereServiceError_1 = __importDefault(require("./utils/SevereServiceError"));
  32. const constants_1 = require("./constants");
  33. const utils_2 = require("./utils");
  34. exports.remote = async function (params = {}, remoteModifier) {
  35. logger_1.default.setLogLevelsConfig(params.logLevels, params.logLevel);
  36. const config = config_1.validateConfig(constants_1.WDIO_DEFAULTS, params, Object.keys(webdriver_1.DEFAULTS));
  37. const automationProtocol = await utils_2.getAutomationProtocol(config);
  38. const modifier = (client, options) => {
  39. Object.assign(options, Object.entries(config)
  40. .reduce((a, [k, v]) => (v == null ? a : { ...a, [k]: v }), {}));
  41. if (typeof remoteModifier === 'function') {
  42. client = remoteModifier(client, options);
  43. }
  44. options.automationProtocol = automationProtocol;
  45. return client;
  46. };
  47. if (params.user && params.key) {
  48. params = Object.assign({}, config_1.detectBackend(params), params);
  49. }
  50. const prototype = utils_2.getPrototype('browser');
  51. const ProtocolDriver = require(automationProtocol).default;
  52. await utils_2.updateCapabilities(params, automationProtocol);
  53. const instance = await ProtocolDriver.newSession(params, modifier, prototype, utils_1.wrapCommand);
  54. if (params.runner && !utils_2.isStub(automationProtocol)) {
  55. const origAddCommand = instance.addCommand.bind(instance);
  56. instance.addCommand = (name, fn, attachToElement) => (origAddCommand(name, utils_1.runFnInFiberContext(fn), attachToElement));
  57. const origOverwriteCommand = instance.overwriteCommand.bind(instance);
  58. instance.overwriteCommand = (name, fn, attachToElement) => (origOverwriteCommand(name, utils_1.runFnInFiberContext(fn), attachToElement));
  59. }
  60. instance.addLocatorStrategy = utils_2.addLocatorStrategyHandler(instance);
  61. return instance;
  62. };
  63. exports.attach = function (params) {
  64. const prototype = utils_2.getPrototype('browser');
  65. return webdriver_1.default.attachToSession(params, undefined, prototype, utils_1.wrapCommand);
  66. };
  67. exports.multiremote = async function (params, { automationProtocol } = {}) {
  68. const multibrowser = new multiremote_1.default();
  69. const browserNames = Object.keys(params);
  70. await Promise.all(browserNames.map(async (browserName) => {
  71. const instance = await exports.remote(params[browserName]);
  72. return multibrowser.addInstance(browserName, instance);
  73. }));
  74. const prototype = utils_2.getPrototype('browser');
  75. const sessionParams = utils_2.isStub(automationProtocol) ? undefined : {
  76. sessionId: '',
  77. isW3C: multibrowser.instances[browserNames[0]].isW3C,
  78. logLevel: multibrowser.instances[browserNames[0]].options.logLevel
  79. };
  80. const ProtocolDriver = automationProtocol && utils_2.isStub(automationProtocol)
  81. ? require(automationProtocol).default
  82. : webdriver_1.default;
  83. const driver = ProtocolDriver.attachToSession(sessionParams, multibrowser.modifier.bind(multibrowser), prototype, utils_1.wrapCommand);
  84. if (!utils_2.isStub(automationProtocol)) {
  85. const origAddCommand = driver.addCommand.bind(driver);
  86. driver.addCommand = (name, fn, attachToElement) => {
  87. origAddCommand(name, utils_1.runFnInFiberContext(fn), attachToElement, Object.getPrototypeOf(multibrowser.baseInstance), multibrowser.instances);
  88. };
  89. const origOverwriteCommand = driver.overwriteCommand.bind(driver);
  90. driver.overwriteCommand = (name, fn, attachToElement) => {
  91. origOverwriteCommand(name, utils_1.runFnInFiberContext(fn), attachToElement, Object.getPrototypeOf(multibrowser.baseInstance), multibrowser.instances);
  92. };
  93. }
  94. driver.addLocatorStrategy = utils_2.addLocatorStrategyHandler(driver);
  95. return driver;
  96. };
  97. exports.SevereServiceError = SevereServiceError_1.default;