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.

getElementObject.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.getElements = exports.getElement = void 0;
  7. const utils_1 = require("@wdio/utils");
  8. const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
  9. const _1 = require(".");
  10. const middlewares_1 = require("../middlewares");
  11. const constants_1 = require("../constants");
  12. exports.getElement = function findElement(selector, res, isReactElement = false) {
  13. const browser = _1.getBrowserObject(this);
  14. const propertiesObject = {
  15. ...lodash_clonedeep_1.default(browser.__propertiesObject__),
  16. ..._1.getPrototype('element'),
  17. scope: { value: 'element' }
  18. };
  19. const element = utils_1.webdriverMonad(this.options, (client) => {
  20. const elementId = _1.getElementFromResponse(res);
  21. if (elementId) {
  22. client.elementId = elementId;
  23. if (this.isW3C) {
  24. client[constants_1.ELEMENT_KEY] = elementId;
  25. }
  26. else {
  27. client.ELEMENT = elementId;
  28. }
  29. }
  30. else {
  31. client.error = res;
  32. }
  33. client.selector = selector;
  34. client.parent = this;
  35. client.emit = this.emit.bind(this);
  36. client.isReactElement = isReactElement;
  37. return client;
  38. }, propertiesObject);
  39. const elementInstance = element(this.sessionId, middlewares_1.elementErrorHandler(utils_1.wrapCommand));
  40. const origAddCommand = elementInstance.addCommand.bind(elementInstance);
  41. elementInstance.addCommand = (name, fn) => {
  42. browser.__propertiesObject__[name] = { value: fn };
  43. origAddCommand(name, utils_1.runFnInFiberContext(fn));
  44. };
  45. return elementInstance;
  46. };
  47. exports.getElements = function getElements(selector, elemResponse, isReactElement = false) {
  48. const browser = _1.getBrowserObject(this);
  49. const propertiesObject = {
  50. ...lodash_clonedeep_1.default(browser.__propertiesObject__),
  51. ..._1.getPrototype('element')
  52. };
  53. const elements = elemResponse.map((res, i) => {
  54. propertiesObject.scope = { value: 'element' };
  55. const element = utils_1.webdriverMonad(this.options, (client) => {
  56. const elementId = _1.getElementFromResponse(res);
  57. if (elementId) {
  58. client.elementId = elementId;
  59. const elementKey = this.isW3C ? constants_1.ELEMENT_KEY : 'ELEMENT';
  60. client[elementKey] = elementId;
  61. }
  62. else {
  63. client.error = res;
  64. }
  65. client.selector = selector;
  66. client.parent = this;
  67. client.index = i;
  68. client.emit = this.emit.bind(this);
  69. client.isReactElement = isReactElement;
  70. return client;
  71. }, propertiesObject);
  72. const elementInstance = element(this.sessionId, middlewares_1.elementErrorHandler(utils_1.wrapCommand));
  73. const origAddCommand = elementInstance.addCommand.bind(elementInstance);
  74. elementInstance.addCommand = (name, fn) => {
  75. browser.__propertiesObject__[name] = { value: fn };
  76. origAddCommand(name, utils_1.runFnInFiberContext(fn));
  77. };
  78. return elementInstance;
  79. });
  80. return elements;
  81. };