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.

selectByVisibleText.js 1.1KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const utils_1 = require("../../utils");
  4. async function selectByVisibleText(text) {
  5. text = typeof text === 'number'
  6. ? text.toString()
  7. : text;
  8. const normalized = text
  9. .trim()
  10. .replace(/\s+/, ' ');
  11. const formatted = /"/.test(normalized)
  12. ? 'concat("' + normalized.split('"').join('", \'"\', "') + '")'
  13. : `"${normalized}"`;
  14. const dotFormat = `[. = ${formatted}]`;
  15. const spaceFormat = `[normalize-space(text()) = ${formatted}]`;
  16. const selections = [
  17. `./option${dotFormat}`,
  18. `./option${spaceFormat}`,
  19. `./optgroup/option${dotFormat}`,
  20. `./optgroup/option${spaceFormat}`,
  21. ];
  22. const optionElement = await this.findElementFromElement(this.elementId, 'xpath', selections.join('|'));
  23. if (optionElement && optionElement.error === 'no such element') {
  24. throw new Error(`Option with text "${text}" not found.`);
  25. }
  26. return this.elementClick(utils_1.getElementFromResponse(optionElement));
  27. }
  28. exports.default = selectByVisibleText;