Search code examples
javascriptautomated-testswebdriverwebdriver-io

How to find a new browser window using webdriver io?


I am writing CoffeeScript tests using Webdriver.io and mocha.

I cannot resize the window in Google Chrome browser. I was told that the window.resizeTo(width, height) command can only resize the window if the window was created by the window.open () command. However, if I create a new window with the window.open() command, I don't know how to find this new window using Webdriver IO. Help me!


Solution

  • it('Sorts the inventory in asc order of price and adds element to cart', async () => {
       await browser.url("https://www.google.com")
       await browser.setWindowSize(200,100)
    });
    

    use serwindowsize if you are using wdio v7 and for new window use:

    await browser.newWindow('https://webdriver.io', { windowName: 'WebdriverIO window', windowFeature: 'width=420,height=230,resizable,scrollbars=yes,status=1', })