webrtc / KITE

KITE is a test engine designed to test WebRTC interoperability across browsers
Apache License 2.0
468 stars 126 forks source link

KITE Dynamic Received Video Check? #118

Closed valdrinnz closed 4 years ago

valdrinnz commented 4 years ago

Is possible with KITE to make Dynamic Received Video Check? We have a test case for monitoring videos, sometimes we need to monitor two feeds, sometimes three etc. Till now we can check videos by editing numberOfParticipants in config file. Is possible to write a script with KITE and check videos without editing the numberOfParticipants, knowing sometimes you have three feeds sometimes four feeds etc.

Our code looks like this: Config File: "numberOfParticipant": 2, ReceivedVideoCheck: `const {TestStep, KiteTestError, Status, TestUtils} = require('kite-common');

/* / class ReceivedVideoCheck extends TestStep { constructor(kiteBaseTest) { super(); this.driver = kiteBaseTest.driver; this.timeout = kiteBaseTest.timeout; this.numberOfParticipant = kiteBaseTest.payload.numberOfParticipant; this.page = kiteBaseTest.page; this.takeScreenshot = kiteBaseTest.takeScreenshot; this.testReporter = kiteBaseTest.reporter; }

  stepDescription() {
    return "Check videos are being received OK";
  }

  async step() {
    let result = "";
    let tmp;
    let error = false;
    try {
        for(let i = 0; i < this.numberOfParticipant; i++){
           // if( i != -1 )
           // {

            tmp = await this.page.videoCheck(this, i);
            result += tmp;
            if (i < this.numberOfParticipant) {
                result += ' | ';
            }
            if (tmp != 'video') {
                error = true;
            }
        }
        if (error) {
            this.testReporter.textAttachment(this.report, "Received videos", result, "plain");
            throw new KiteTestError(Status.FAILED, "Some videos are still or blank: " + result);
        }
    } 
//}
     catch (error) {
      console.log(error);
      if (error instanceof KiteTestError) {
        throw error;
      } else {
        throw new KiteTestError(Status.BROKEN, "Error looking for the video");
      }
    }
    if (this.takeScreenshot) {
      let screenshot = await TestUtils.takeScreenshot(this.driver);
      this.testReporter.screenshotAttachment(this.report, "Screenshot step", screenshot); 
    }
  }
}

module.exports = ReceivedVideoCheck; MainPage: async videoCheck(stepInfo, index) { let checked; let i; let timeout = stepInfo.timeout; await TestUtils.waitForVideos(stepInfo, videos); checked = await verifyVideoDisplayByIndex(stepInfo.driver, index); while(checked.result === 'blank' && i < timeout) { checked = await verifyVideoDisplayByIndex(stepInfo.driver, index); i++; await waitAround(1000); } return checked.result; }

async getVideos() { return videos; }`

namvuCosmo commented 4 years ago

Hello,

For this, I think you should try something along the line of checking the number of video elements on the page. I'm not sure about this syntax, I haven't use the Js API in a while:

let numberOfVideo = webdriver.findElements(By.tagName('video')).lenght();

and then use this numberOfVideo instead of your numberOfParticipant.

Let me know if it works 😄

valdrinnz commented 4 years ago

No it doesn't work!

namvuCosmo commented 4 years ago

It doesn't work because you could get the number of video element on the page?

Did you get any error?

Is there any way to get the number of video feed you have? You can put a text displaying that on the page and get that by element.getText().

Is there an API on your web app that allow getting this number of participants by executing Js on the browser console? You can execute that with the webdriver's API to retrieve this value.

What else have you tried?

It is possible to write a script to check it dynamically, but I can't write the script for you. I can suggest some ideas, but if your only feed back is "it doesn't work" then I can't further develop these ideas.

namvuCosmo commented 4 years ago

closed till more info