Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Toolbar.ts 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. // eslint-disable-next-line no-unused-vars
  2. import { Participant } from '../helpers/Participant';
  3. const AUDIO_MUTE = 'Mute microphone';
  4. const AUDIO_UNMUTE = 'Unmute microphone';
  5. const CLOSE_PARTICIPANTS_PANE = 'Close participants pane';
  6. const OVERFLOW_MENU = 'More actions menu';
  7. const OVERFLOW = 'More actions';
  8. const PARTICIPANTS = 'Open participants pane';
  9. const VIDEO_QUALITY = 'Manage video quality';
  10. const VIDEO_MUTE = 'Stop camera';
  11. const VIDEO_UNMUTE = 'Start camera';
  12. /**
  13. * The toolbar elements.
  14. */
  15. export default class Toolbar {
  16. private participant: Participant;
  17. /**
  18. * Creates toolbar for a participant.
  19. *
  20. * @param {Participant} participant - The participants.
  21. */
  22. constructor(participant: Participant) {
  23. this.participant = participant;
  24. }
  25. /**
  26. * Returns the button.
  27. *
  28. * @param {string} accessibilityCSSSelector - The selector to find the button.
  29. * @returns {WebdriverIO.Element} The button.
  30. * @private
  31. */
  32. private getButton(accessibilityCSSSelector: string) {
  33. return this.participant.driver.$(`[aria-label^="${accessibilityCSSSelector}"]`);
  34. }
  35. /**
  36. * The audio mute button.
  37. */
  38. get audioMuteBtn() {
  39. return this.getButton(AUDIO_MUTE);
  40. }
  41. /**
  42. * The audio unmute button.
  43. */
  44. get audioUnMuteBtn() {
  45. return this.getButton(AUDIO_UNMUTE);
  46. }
  47. /**
  48. * Clicks audio mute button.
  49. *
  50. * @returns {Promise<void>}
  51. */
  52. async clickAudioMuteButton(): Promise<void> {
  53. this.participant.log('Clicking on: Audio Mute Button');
  54. await this.audioMuteBtn.click();
  55. }
  56. /**
  57. * Clicks audio unmute button.
  58. *
  59. * @returns {Promise<void>}
  60. */
  61. async clickAudioUnmuteButton(): Promise<void> {
  62. this.participant.log('Clicking on: Audio Unmute Button');
  63. await this.audioUnMuteBtn.click();
  64. }
  65. /**
  66. * The video mute button.
  67. */
  68. get videoMuteBtn() {
  69. return this.getButton(VIDEO_MUTE);
  70. }
  71. /**
  72. * The video unmute button.
  73. */
  74. get videoUnMuteBtn() {
  75. return this.getButton(VIDEO_UNMUTE);
  76. }
  77. /**
  78. * Clicks video mute button.
  79. *
  80. * @returns {Promise<void>}
  81. */
  82. async clickVideoMuteButton(): Promise<void> {
  83. this.participant.log('Clicking on: Video Mute Button');
  84. await this.videoMuteBtn.click();
  85. }
  86. /**
  87. * Clicks video unmute button.
  88. *
  89. * @returns {Promise<void>}
  90. */
  91. async clickVideoUnmuteButton(): Promise<void> {
  92. this.participant.log('Clicking on: Video Unmute Button');
  93. await this.videoUnMuteBtn.click();
  94. }
  95. /**
  96. * Clicks Participants pane button.
  97. *
  98. * @returns {Promise<void>}
  99. */
  100. async clickCloseParticipantsPaneButton(): Promise<void> {
  101. this.participant.log('Clicking on: Close Participants pane Button');
  102. await this.getButton(CLOSE_PARTICIPANTS_PANE).click();
  103. }
  104. /**
  105. * Clicks Participants pane button.
  106. *
  107. * @returns {Promise<void>}
  108. */
  109. async clickParticipantsPaneButton(): Promise<void> {
  110. this.participant.log('Clicking on: Participants pane Button');
  111. await this.getButton(PARTICIPANTS).click();
  112. }
  113. /**
  114. * Clicks on the video quality toolbar button which opens the
  115. * dialog for adjusting max-received video quality.
  116. */
  117. async clickVideoQualityButton(): Promise<void> {
  118. return this.clickButtonInOverflowMenu(VIDEO_QUALITY);
  119. }
  120. /**
  121. * Ensure the overflow menu is open and clicks on a specified button.
  122. * @param accessibilityLabel The accessibility label of the button to be clicked.
  123. * @private
  124. */
  125. private async clickButtonInOverflowMenu(accessibilityLabel: string) {
  126. await this.openOverflowMenu();
  127. await this.getButton(accessibilityLabel).click();
  128. await this.closeOverflowMenu();
  129. }
  130. /**
  131. * Checks if the overflow menu is open and visible.
  132. * @private
  133. */
  134. private async isOverflowMenuOpen() {
  135. return await this.participant.driver.$$(`[aria-label^="${OVERFLOW_MENU}"]`).length > 0;
  136. }
  137. /**
  138. * Clicks on the overflow toolbar button which opens or closes the overflow menu.
  139. * @private
  140. */
  141. private async clickOverflowButton(): Promise<void> {
  142. await this.getButton(OVERFLOW).click();
  143. }
  144. /**
  145. * Ensure the overflow menu is displayed.
  146. * @private
  147. */
  148. private async openOverflowMenu() {
  149. if (await this.isOverflowMenuOpen()) {
  150. return;
  151. }
  152. await this.clickOverflowButton();
  153. await this.waitForOverFlowMenu(true);
  154. }
  155. /**
  156. * Ensures the overflow menu is not displayed.
  157. * @private
  158. */
  159. private async closeOverflowMenu() {
  160. if (!await this.isOverflowMenuOpen()) {
  161. return;
  162. }
  163. await this.clickOverflowButton();
  164. await this.waitForOverFlowMenu(false);
  165. }
  166. /**
  167. * Waits for the overflow menu to be visible or hidden.
  168. * @param visible
  169. * @private
  170. */
  171. private async waitForOverFlowMenu(visible: boolean) {
  172. await this.participant.driver.$(`[aria-label^="${OVERFLOW_MENU}"]`).waitForDisplayed({
  173. reverse: !visible,
  174. timeout: 3000,
  175. timeoutMsg: `Overflow menu is not ${visible ? 'visible' : 'hidden'}`
  176. });
  177. }
  178. }