feat: set view port for ENTIRE context

This commit is contained in:
karishmas6
2024-10-18 16:35:18 +05:30
parent 532ab38874
commit 14bbb7d6d0

View File

@@ -90,7 +90,12 @@ export class RemoteBrowser {
*/
public initialize = async (options: RemoteBrowserOptions): Promise<void> => {
this.browser = <Browser>(await options.browser.launch(options.launchOptions));
const context = await this.browser.newContext();
const context = await this.browser.newContext(
{
viewport: { height: 500, width: 900 },
// recordVideo: { dir: 'videos/' }
}
);
this.currentPage = await context.newPage();
const blocker = await PlaywrightBlocker.fromPrebuiltAdsAndTracking(fetch);
await blocker.enableBlockingInPage(this.currentPage);
@@ -275,7 +280,7 @@ export class RemoteBrowser {
if (page) {
await this.stopScreencast();
this.currentPage = page;
await this.currentPage.setViewportSize({ height: 500, width: 1280 })
await this.currentPage.setViewportSize({ height: 500, width: 900 })
this.client = await this.currentPage.context().newCDPSession(this.currentPage);
this.socket.emit('urlChanged', this.currentPage.url());
await this.makeAndEmitScreenshot();