How to set viewport in WDIO V6?

195 Views Asked by At

Is there a way to set viewport in current version of WebDriverIO i.e. V6(async)? I want to set responsive dimensions for the inner browser and not outer browser size.

I tried to zoom out using :

  await browser.executeAsync((done) => { done(document.body.style.zoom = '25%'); });

so that I can view the whole page view on the screen entirely but the actions like clicking on the elements doesn't happen because the css properties changes and it gives me following error:

element click intercepted: Element ... is not clickable at point (561, 72). Other element would receive the clickI tried to zoom out using :

1

There are 1 best solutions below

0
On

Looks like you are on the right lines but the latest version is v7 so your commands might not work for that reason. The only mention of changing window size is https://webdriver.io/docs/api/browser/setWindowSize/

Maybe try to zoom? https://webdriver.io/docs/api/webdriver/#performactions

browser.performActions(driver)
    .sendKeys(html, Keys.CONTROL, Keys.ADD, Keys.NULL)
    .perform();

Just make sure you zoom out if you need to.