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.

elementSendKeys.js 1.2KB

12345678910111213141516171819202122232425262728293031
  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. const path_1 = __importDefault(require("path"));
  7. const utils_1 = require("../utils");
  8. async function elementSendKeys({ elementId, text }) {
  9. var _a, _b;
  10. const elementHandle = await this.elementStore.get(elementId);
  11. if (!elementHandle) {
  12. throw utils_1.getStaleElementError(elementId);
  13. }
  14. await elementHandle.focus();
  15. const page = this.getPageHandle();
  16. const propertyHandles = {
  17. tagName: await elementHandle.getProperty('tagName'),
  18. type: await elementHandle.getProperty('type')
  19. };
  20. const tagName = await ((_a = propertyHandles.tagName) === null || _a === void 0 ? void 0 : _a.jsonValue());
  21. const type = await ((_b = propertyHandles.type) === null || _b === void 0 ? void 0 : _b.jsonValue());
  22. if (tagName === 'INPUT' && type === 'file') {
  23. const paths = (text || '').split('\n').map(p => path_1.default.resolve(p));
  24. await elementHandle.uploadFile(...paths);
  25. }
  26. else {
  27. await page.keyboard.type(text);
  28. }
  29. return null;
  30. }
  31. exports.default = elementSendKeys;