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.

VideoQualityDialog.ts 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { Key } from 'webdriverio';
  2. import BaseDialog from './BaseDialog';
  3. const VIDEO_QUALITY_SLIDER_CLASS = 'custom-slider';
  4. /**
  5. * The video quality dialog.
  6. */
  7. export default class VideoQualityDialog extends BaseDialog {
  8. /**
  9. * Opens the video quality dialog and sets the video quality to the minimum or maximum definition.
  10. * @param audioOnly - Whether to set the video quality to audio only (minimum).
  11. * @private
  12. */
  13. async setVideoQuality(audioOnly: boolean) {
  14. await this.participant.getToolbar().clickVideoQualityButton();
  15. const videoQualitySlider = this.participant.driver.$(`.${VIDEO_QUALITY_SLIDER_CLASS}`);
  16. const audioOnlySliderValue = parseInt(await videoQualitySlider.getAttribute('min'), 10);
  17. const maxDefinitionSliderValue = parseInt(await videoQualitySlider.getAttribute('max'), 10);
  18. const activeValue = parseInt(await videoQualitySlider.getAttribute('value'), 10);
  19. const targetValue = audioOnly ? audioOnlySliderValue : maxDefinitionSliderValue;
  20. const distanceToTargetValue = targetValue - activeValue;
  21. const keyDirection = distanceToTargetValue > 0 ? Key.ArrowRight : Key.ArrowLeft;
  22. // we need to click the element to activate it so it will receive the keys
  23. await videoQualitySlider.click();
  24. // Move the slider to the target value.
  25. for (let i = 0; i < Math.abs(distanceToTargetValue); i++) {
  26. await this.participant.driver.keys(keyDirection);
  27. }
  28. // Close the video quality dialog.
  29. await this.clickCloseButton();
  30. }
  31. }