I would like to set the window-position within the total available screen, so it takes up half of the screen-size and is positioned at the right end of the screen with its right border. Couldn't find any docs about it, maybe it's not possible?
As the docs state, the args
-option of openBrowser()
accepts all of the Chromium browser launch options and the nodejs-package "robotjs" helps to get the screen-size. Also "screenres" claims to able to do that, but I haven't tested it.
This opens the browser-window with half of the screen-width, and positions it to be right-aligned within the screen:
const { closeBrowser, openBrowser } = require('taiko')
const screenSize = require('robotjs').getScreenSize()
const screenWidth = screenSize.width / 2
const screenHeight = screenSize.height
const windowSize = '--window-size=' + screenWidth + ',' + screenHeight
const windowPosition = '--window-position=' + screenWidth + ',0'
async () => {
try {
await openBrowser({ args: [ windowPosition, windowSize ] })
} catch (error) {
console.error(error);
} finally {
await closeBrowser();
}
})();