diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.ts index 3fb140ee57..43742f6fbd 100644 --- a/tests/helpers/Participant.ts +++ b/tests/helpers/Participant.ts @@ -191,8 +191,8 @@ export class Participant { * @param {string} message - The message to log. * @returns {void} */ - log(message: string): void { - logInfo(this.driver, message); + async log(message: string): Promise { + await logInfo(this.driver, message); } /** diff --git a/tests/helpers/browserLogger.ts b/tests/helpers/browserLogger.ts index 46bec40883..4ba66c5e23 100644 --- a/tests/helpers/browserLogger.ts +++ b/tests/helpers/browserLogger.ts @@ -70,17 +70,14 @@ export function saveLogs(driver: WebdriverIO.Browser, value: string) { * @param {string} message - The message to add. * @returns {void} */ -export function logInfo(driver: WebdriverIO.Browser, message: string) { +export async function logInfo(driver: WebdriverIO.Browser, message: string) { // @ts-ignore if (!driver.logFile) { return; } - try { - // @ts-ignore - fs.appendFileSync(driver.logFile, `${new Date().toISOString()} ${LOG_PREFIX} ${message}\n`); - } catch (err) { - console.error(err); - } + return driver.execute((prefix, msg) => + console.log(`${new Date().toISOString()} ${prefix} ${msg}\n`), + LOG_PREFIX, message); } diff --git a/tests/pageobjects/InviteDialog.ts b/tests/pageobjects/InviteDialog.ts index ce06cc29c5..66bb4031ec 100644 --- a/tests/pageobjects/InviteDialog.ts +++ b/tests/pageobjects/InviteDialog.ts @@ -51,7 +51,7 @@ export default class InviteDialog extends BaseDialog { const fullText = await elem.getText(); - this.participant.log(`Extracted text in invite dialog: ${fullText}`); + await this.participant.log(`Extracted text in invite dialog: ${fullText}`); return fullText.split(':')[1].trim(); } diff --git a/tests/pageobjects/Toolbar.ts b/tests/pageobjects/Toolbar.ts index ba2ce166e5..1a7def7bbc 100644 --- a/tests/pageobjects/Toolbar.ts +++ b/tests/pageobjects/Toolbar.ts @@ -55,8 +55,8 @@ export default class Toolbar extends BasePageObject { * * @returns {Promise} */ - clickAudioMuteButton(): Promise { - this.participant.log('Clicking on: Audio Mute Button'); + async clickAudioMuteButton(): Promise { + await this.participant.log('Clicking on: Audio Mute Button'); return this.audioMuteBtn.click(); } @@ -66,8 +66,8 @@ export default class Toolbar extends BasePageObject { * * @returns {Promise} */ - clickAudioUnmuteButton(): Promise { - this.participant.log('Clicking on: Audio Unmute Button'); + async clickAudioUnmuteButton(): Promise { + await this.participant.log('Clicking on: Audio Unmute Button'); return this.audioUnMuteBtn.click(); } @@ -91,8 +91,8 @@ export default class Toolbar extends BasePageObject { * * @returns {Promise} */ - clickVideoMuteButton(): Promise { - this.participant.log('Clicking on: Video Mute Button'); + async clickVideoMuteButton(): Promise { + await this.participant.log('Clicking on: Video Mute Button'); return this.videoMuteBtn.click(); } @@ -102,8 +102,8 @@ export default class Toolbar extends BasePageObject { * * @returns {Promise} */ - clickVideoUnmuteButton(): Promise { - this.participant.log('Clicking on: Video Unmute Button'); + async clickVideoUnmuteButton(): Promise { + await this.participant.log('Clicking on: Video Unmute Button'); return this.videoUnMuteBtn.click(); } @@ -113,8 +113,8 @@ export default class Toolbar extends BasePageObject { * * @returns {Promise} */ - clickCloseParticipantsPaneButton(): Promise { - this.participant.log('Clicking on: Close Participants pane Button'); + async clickCloseParticipantsPaneButton(): Promise { + await this.participant.log('Clicking on: Close Participants pane Button'); return this.getButton(CLOSE_PARTICIPANTS_PANE).click(); } @@ -124,8 +124,8 @@ export default class Toolbar extends BasePageObject { * * @returns {Promise} */ - clickParticipantsPaneButton(): Promise { - this.participant.log('Clicking on: Participants pane Button'); + async clickParticipantsPaneButton(): Promise { + await this.participant.log('Clicking on: Participants pane Button'); // Special case for participants pane button, as it contains the number of participants and its label // is changing @@ -150,8 +150,8 @@ export default class Toolbar extends BasePageObject { /** * Clicks on the raise hand button that enables participants will to speak. */ - clickRaiseHandButton(): Promise { - this.participant.log('Clicking on: Raise hand Button'); + async clickRaiseHandButton(): Promise { + await this.participant.log('Clicking on: Raise hand Button'); return this.getButton(RAISE_HAND).click(); } @@ -159,8 +159,8 @@ export default class Toolbar extends BasePageObject { /** * Clicks on the chat button that opens chat panel. */ - clickChatButton(): Promise { - this.participant.log('Clicking on: Chat Button'); + async clickChatButton(): Promise { + await this.participant.log('Clicking on: Chat Button'); return this.getButton(CHAT).click(); } @@ -168,8 +168,8 @@ export default class Toolbar extends BasePageObject { /** * Clicks on the chat button that closes chat panel. */ - clickCloseChatButton(): Promise { - this.participant.log('Clicking on: Close Chat Button'); + async clickCloseChatButton(): Promise { + await this.participant.log('Clicking on: Close Chat Button'); return this.getButton(CLOSE_CHAT).click(); } @@ -205,8 +205,8 @@ export default class Toolbar extends BasePageObject { /** * Clicks on the hangup button that ends the conference. */ - clickHangupButton(): Promise { - this.participant.log('Clicking on: Hangup Button'); + async clickHangupButton(): Promise { + await this.participant.log('Clicking on: Hangup Button'); return this.getButton(HANGUP).click(); } @@ -237,7 +237,7 @@ export default class Toolbar extends BasePageObject { // so let's move focus away before clicking the button await this.participant.driver.$('#overflow-context-menu').moveTo(); - this.participant.log(`Clicking on: ${accessibilityLabel}`); + await this.participant.log(`Clicking on: ${accessibilityLabel}`); await this.getButton(accessibilityLabel).click(); await this.closeOverflowMenu(); diff --git a/tests/specs/media/activeSpeaker.spec.ts b/tests/specs/media/activeSpeaker.spec.ts index 39f7e76544..309373e564 100644 --- a/tests/specs/media/activeSpeaker.spec.ts +++ b/tests/specs/media/activeSpeaker.spec.ts @@ -272,19 +272,19 @@ describe('Active speaker', () => { */ async function testActiveSpeaker( activeSpeaker: Participant, otherParticipant1: Participant, otherParticipant2: Participant) { - activeSpeaker.log(`Start testActiveSpeaker for participant: ${activeSpeaker.name}`); + await activeSpeaker.log(`Start testActiveSpeaker for participant: ${activeSpeaker.name}`); const speakerEndpoint = await activeSpeaker.getEndpointId(); // just a debug print to go in logs - activeSpeaker.log('Unmuting in testActiveSpeaker'); + await activeSpeaker.log('Unmuting in testActiveSpeaker'); // Unmute await activeSpeaker.getToolbar().clickAudioUnmuteButton(); // just a debug print to go in logs - otherParticipant1.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`); - otherParticipant2.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`); + await otherParticipant1.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`); + await otherParticipant2.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`); await activeSpeaker.getFilmstrip().assertAudioMuteIconIsDisplayed(activeSpeaker, true); @@ -297,14 +297,14 @@ async function testActiveSpeaker( 30_000); // 30 seconds // just a debug print to go in logs - activeSpeaker.log('Muting in testActiveSpeaker'); + await activeSpeaker.log('Muting in testActiveSpeaker'); // Mute back again await activeSpeaker.getToolbar().clickAudioMuteButton(); // just a debug print to go in logs - otherParticipant1.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`); - otherParticipant2.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`); + await otherParticipant1.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`); + await otherParticipant2.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`); await otherParticipant1.getFilmstrip().assertAudioMuteIconIsDisplayed(activeSpeaker); } diff --git a/tests/specs/media/startMuted.spec.ts b/tests/specs/media/startMuted.spec.ts index 02a9693bca..7d58a0573b 100644 --- a/tests/specs/media/startMuted.spec.ts +++ b/tests/specs/media/startMuted.spec.ts @@ -127,7 +127,7 @@ describe('Start muted', () => { const p2ID = await p2.getEndpointId(); - p1.log(`Start configOptionsTest, second participant: ${p2ID}`); + await p1.log(`Start configOptionsTest, second participant: ${p2ID}`); // Participant 3 should be muted, 1 and 2 unmuted. await p3.getFilmstrip().assertAudioMuteIconIsDisplayed(p3); @@ -148,7 +148,7 @@ describe('Start muted', () => { await p1.getToolbar().clickAudioMuteButton(); await p2.getToolbar().clickAudioMuteButton(); await p3.getToolbar().clickAudioUnmuteButton(); - p1.log('configOptionsTest, unmuted third participant'); + await p1.log('configOptionsTest, unmuted third participant'); await p1.waitForAudioMuted(p3, false /* unmuted */); });