Testim Documentation

Welcome to the Testim documentation. You'll find comprehensive guides to help you get started quickly, example code snippets, and tips for being more productive. You will also find details about advanced features that allow you to customize Testim to fit your environment or special testing conditions. Don't worry, we'll support you if you get stuck. Let's jump right in!

Guides    Changelog

resize(options)

This method resizes the browser window to the given x,y size coordinates.

  • options {object}
    • width {number} window width
    • height {number} the window height
  • returns: Promise that fulfills when the window has been resized

Note: the browser size is limited by what the browser, computer and grid can actually resize to. You can't for example resize a browser to 10px by 10px or 100000px by 10000px.

For example:

// ✅ resize to 1024/768
await resize({
  width: 1024,
  height: 768
});
// ✅ resize to 1280/1024
await resize({
  width: 1280,
  height: 1024
});
// ❌ this method resizes the whole browser window and not an element
await resize('body', {
  width: 1280,
  height: 1024
});
// ❌ it's over 9000! (so too big of a page)
await resize('body', {
  width: 9001,
  height: 9001
});

Full example:

'use strict';

const expect = require('chai').expect;
const { go, it, describe, getCookie, setCookie, evaluate } = require('testim');

describe('cookies', () => {
   
  test("resize", async () => {
      await go('http://jsbin.testim.io/quh/1');
      const oldWidth = await evaluate(() => document.body.getClientRects()[0].width);
      await resize({ width: 550, height: 550}); // 500 is the minimum size of Chrome
      const newWidth = await evaluate(() => document.body.getClientRects()[0].width);
      expect(oldWidth).to.not.equal(newWidth);
  });
  
});

Updated about a month ago

resize(options)


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.