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.

switchToFrame.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const constants_1 = require("../constants");
  4. const utils_1 = require("../utils");
  5. async function switchToFrame({ id }) {
  6. const page = this.getPageHandle(true);
  7. if (id === null && typeof page.parentFrame === 'function') {
  8. let parentFrame = await page.parentFrame();
  9. while (parentFrame) {
  10. parentFrame = await parentFrame.parentFrame();
  11. }
  12. this.currentFrame = parentFrame;
  13. return null;
  14. }
  15. const idAsElementReference = id;
  16. if (typeof idAsElementReference[constants_1.ELEMENT_KEY] === 'string') {
  17. const elementHandle = await this.elementStore.get(idAsElementReference[constants_1.ELEMENT_KEY]);
  18. if (!elementHandle) {
  19. throw utils_1.getStaleElementError(id);
  20. }
  21. const contentFrame = await elementHandle.contentFrame();
  22. if (!contentFrame) {
  23. throw new Error('no such frame');
  24. }
  25. this.currentFrame = contentFrame;
  26. return null;
  27. }
  28. if (typeof id === 'number') {
  29. let getFrames = page.frames || page.childFrames;
  30. const childFrames = await getFrames.apply(page);
  31. const childFrame = childFrames[id];
  32. if (!childFrame) {
  33. throw new Error('no such frame');
  34. }
  35. this.currentFrame = childFrame;
  36. return null;
  37. }
  38. throw new Error(`Could not switch frame, unknwon id: ${id}`);
  39. }
  40. exports.default = switchToFrame;