Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

IframeAPI.ts 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { LOG_PREFIX } from '../helpers/browserLogger';
  2. import BasePageObject from './BasePageObject';
  3. /**
  4. * The Iframe API and helpers from iframeAPITest.html
  5. */
  6. export default class IframeAPI extends BasePageObject {
  7. /**
  8. * Returns the json object from the iframeAPI helper.
  9. * @param event
  10. */
  11. async getEventResult(event: string): Promise<any> {
  12. return await this.participant.driver.execute(
  13. eventName => {
  14. const result = window.jitsiAPI.test[eventName];
  15. if (!result) {
  16. return false;
  17. }
  18. return result;
  19. }, event);
  20. }
  21. /**
  22. * Adds an event listener to the iframeAPI.
  23. * @param eventName The event name.
  24. */
  25. async addEventListener(eventName: string) {
  26. return await this.participant.driver.execute(
  27. (event, prefix) => {
  28. console.log(`${new Date().toISOString()} ${prefix} Adding listener for event: ${event}`);
  29. window.jitsiAPI.addListener(event, evt => {
  30. console.log(
  31. `${new Date().toISOString()} ${prefix} Received ${event} event: ${JSON.stringify(evt)}`);
  32. window.jitsiAPI.test[event] = evt;
  33. });
  34. }, eventName, LOG_PREFIX);
  35. }
  36. /**
  37. * Returns an array of available rooms and details of it.
  38. */
  39. async getRoomsInfo() {
  40. return await this.participant.driver.execute(() => window.jitsiAPI.getRoomsInfo());
  41. }
  42. /**
  43. * Returns the number of participants in the conference.
  44. */
  45. async getNumberOfParticipants() {
  46. return await this.participant.driver.execute(() => window.jitsiAPI.getNumberOfParticipants());
  47. }
  48. /**
  49. * Executes command using iframeAPI.
  50. * @param command The command.
  51. * @param args The arguments.
  52. */
  53. async executeCommand(command: string, ...args: any[]) {
  54. return await this.participant.driver.execute(
  55. (commandName, commandArgs) =>
  56. window.jitsiAPI.executeCommand(commandName, ...commandArgs)
  57. , command, args);
  58. }
  59. /**
  60. * Returns the current state of the participant's pane.
  61. */
  62. async isParticipantsPaneOpen() {
  63. return await this.participant.driver.execute(() => window.jitsiAPI.isParticipantsPaneOpen());
  64. }
  65. /**
  66. * Removes the embedded Jitsi Meet conference.
  67. */
  68. async dispose() {
  69. return await this.participant.driver.execute(() => window.jitsiAPI.dispose());
  70. }
  71. }