Closed valdrinnz closed 4 years ago
Hello,
I'm sorry but we currently don't have the capacity to maintain our JS libraries. But thanks for your post, we will investigate this in the future.
Hello, namvu
Thank you for your response, already fixed it. In mainpage, I changed getPeerConnectionScript function: `const getPeerConnectionScript = function() { return "window.pc = [];"
And now WebRTC Stats are coming.
Cool!
So initially the window.peerConnections was a map, not an [ ], I guess if you put window.peerConnections[0].peerConnection
instead of window.peerConnections[0]
it might have worked as well.
Yes that works too.
I have written below scripts and I get this computePacketLoss:
GetStatsStep: `const {TestUtils, TestStep, Status, KiteTestError} = require('kite-common');
class GetStatsStep extends TestStep { constructor(kiteBaseTest) { super(); this.driver = kiteBaseTest.driver; this.statsCollectionTime = kiteBaseTest.statsCollectionTime; this.statsCollectionInterval = kiteBaseTest.statsCollectionInterval; this.selectedStats = kiteBaseTest.selectedStats; this.page = kiteBaseTest.page; this.peerConnections = kiteBaseTest.peerConnections;
}
stepDescription() { return 'Getting WebRTC stats via getStats'; }
async step() { try { let rawStats = await this.page.getStats(this); let summaryStats = TestUtils.extractJson(rawStats, 'both'); // // Data this.testReporter.textAttachment(this.report, 'GetStatsRaw', JSON.stringify(rawStats, null, 4), "json"); this.testReporter.textAttachment(this.report, 'GetStatsSummary', JSON.stringify(summaryStats, null, 4), "json"); } catch (error) { console.log(error); throw new KiteTestError(Status.BROKEN, "Failed to getStats"); } } }
module.exports = GetStatsStep;`
In my web app console peerConnections are appearing here:
In main page: `const getPeerConnectionScript = function() { return "window.peerConnections = peerConnections[0];";
async getStats(stepInfo) { await stepInfo.driver.executeScript(getPeerConnectionScript()); let stats = await TestUtils.getStats(stepInfo, 'kite', stepInfo.peerConnections[0]); return stats; } }`
config file:
"getStats" : { "enabled": true, "statsCollectionTime": 2, "statsCollectionInterval": 1, "peerConnections": ["window.peerConnections[0];"], "selectedStats": [ "inbound-rtp", "outbound-rtp", "candidate-pair" , "ontrack"] },
testScript:
if (this.getStats) { let getStatsStep = new GetStatsStep(this); await getStatsStep.execute(this); }
In my console there is this message:
In allure report:
How is possible to fix computePacketLoss ?