Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to resize the innerWidth & innerHeight for Non Headless Chrome? #943

Closed
Nurutomo opened this issue Oct 15, 2020 · 11 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@Nurutomo
Copy link

Currently the default innerSize is 1440 by 900
With that size, my window cropping it (My screen resolution is 1366 by 768)
image

Console Debugger:
image

My expectation is the innerSize matching the windowSize

@smashah
Copy link
Member

smashah commented Oct 15, 2020

@Nurutomo

You can change this in your create config

create({
	puppeteerConfig: {
		width : 1366,
		height: 768	
	}
})

@Nurutomo
Copy link
Author

Nurutomo commented Oct 15, 2020

doesn't work

code:

const { create, Client } = require('@open-wa/wa-automate')

create('nurutomo', {
    headless: false,
    useChrome: true,
    puppeteerConfig: {
	width : 1366,
	height: 768	
    }
})
.then(client => start(client))
.catch(err => new Error(err))

function start(client = new Client()) {
    client.onAnyMessage(msg => {
        console.log(msg.sender.pushname || msg.sender.verifiedName || msg.sender.formattedName, msg.body || msg.caption)
    })
}

@smashah smashah self-assigned this Oct 15, 2020
@smashah smashah added the enhancement New feature or request label Oct 15, 2020
@smashah
Copy link
Member

smashah commented Oct 15, 2020

My mistake, that is not implemented yet.

@Nurutomo
Copy link
Author

similar issue puppeteer/puppeteer#1183

@Nurutomo
Copy link
Author

const puppeteerConfig = {
WAUrl: 'https://web.whatsapp.com',
width: 1440,
height: 900,
chromiumArgs: [

@smashah
Copy link
Member

smashah commented Oct 15, 2020

yep. on the todo list

@Nurutomo
Copy link
Author

about right here needs change

export async function initClient(sessionId?: string, config?:ConfigObject, customUserAgent?:string) {
if(config?.useStealth) puppeteer.use(require('puppeteer-extra-plugin-stealth')());
browser = await initBrowser(sessionId,config);
const waPage = await getWAPage(browser);
if (config?.proxyServerCredentials) {
await waPage.authenticate(config.proxyServerCredentials);
}
await waPage.setUserAgent(customUserAgent||useragent);
await waPage.setViewport({
width,
height,
deviceScaleFactor: 1
});

@smashah
Copy link
Member

smashah commented Oct 15, 2020

Yes, I know..

@smashah
Copy link
Member

smashah commented Oct 15, 2020

@github-actions run

⚡ Release! ⚡
(async () => {
function exec(cmd) {
  console.log(execSync(cmd).toString());
}

// Config
const gitUserEmail = "github-actions[bot]@users.noreply.github.com";
const gitUserName = "github-actions[bot]";

exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`);
exec(`git config --global user.email "${gitUserEmail}"`);
exec(`git config --global user.name "${gitUserName}"`);
exec(`npm i`);
exec(`npm run release-ci`);

//comment on the issue
var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString();

    await postComment(result);

//create changelog image
exec(`npm run release-image`);
exec(`git commit -a -m 'updated release-image'`);
exec(`git push --force`);
  })();

@Nurutomo
Copy link
Author

viewport: {
// width: 1920,
height: 1200
}

Uhmm...I tried the options/config above, it doesnt work. i renamed key from viewport to window and its working

Working code

const { create, Client } = require('@open-wa/wa-automate')

create('nurutomo', {
    headless: false,
    useChrome: true,
//  viewport: {
    window: {
        width : 1280,
        height: 720
     }
}).then((client) => start(client))

function start(client = new Client()) {
    client.onAnyMessage(message => {
        let name = message.sender.pushname || message.sender.verifiedName || message.sender.formattedName
        let text = message.body || message.caption
        console.log(`(${name}) ${text}`)
    })
}

await waPage.setViewport({
width: config?.window?.width || width,
height: config?.window?.height || height,
deviceScaleFactor: 1
});

@smashah
Copy link
Member

smashah commented Oct 16, 2020

working as viewport in 2.1.4

smashah added a commit that referenced this issue Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants