Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,14 @@ class Playwright extends Helper {
}

if (this.options.video) {
this.options.recordVideo = { size: parseWindowSize(this.options.windowSize) };
// set the video resolution with window size
let size = parseWindowSize(this.options.windowSize);

// if the video resolution is passed, set the record resoultion with that resolution
if (this.options.recordVideo && this.options.recordVideo.size) {
size = parseWindowSize(this.options.recordVideo.size);
}
this.options.recordVideo = { size };
}
if (this.options.recordVideo && !this.options.recordVideo.dir) {
this.options.recordVideo.dir = `${global.output_dir}/videos/`;
Expand Down Expand Up @@ -3656,6 +3663,11 @@ async function targetCreatedHandler(page) {

function parseWindowSize(windowSize) {
if (!windowSize) return { width: 800, height: 600 };

if (windowSize.width && windowSize.height) {
return { width: parseInt(windowSize.width, 10), height: parseInt(windowSize.height, 10) };
}

const dimensions = windowSize.split('x');
if (dimensions.length < 2 || windowSize === 'maximize') {
console.log('Invalid window size, setting window to default values');
Expand Down
12 changes: 7 additions & 5 deletions test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,6 @@ describe('Playwright - Performance Metrics', () => {
show: false,
restart: true,
browser: 'chromium',
trace: true,
video: true,
});
I._init();
return I._beforeSuite();
Expand All @@ -1332,7 +1330,6 @@ describe('Playwright - Performance Metrics', () => {
webApiTests.init({
I, siteUrl,
});
deleteDir(path.join(global.output_dir, 'video'));
return I._before().then(() => {
page = I.page;
browser = I.browser;
Expand All @@ -1346,7 +1343,6 @@ describe('Playwright - Performance Metrics', () => {
it('grabs performance metrics', async () => {
await I.amOnPage('https://codecept.io');
const metrics = await I.grabMetrics();
console.log(metrics);
expect(metrics.length).to.greaterThan(0);
expect(metrics[0].name).to.equal('Timestamp');
});
Expand All @@ -1361,12 +1357,18 @@ describe('Playwright - Video & Trace & HAR', () => {

I = new Playwright({
url: siteUrl,
windowSize: '500x700',
windowSize: '300x500',
show: false,
restart: true,
browser: 'chromium',
trace: true,
video: true,
recordVideo: {
size: {
width: 400,
height: 600,
},
},
recordHar: {},
});
I._init();
Expand Down