Show List

Window Resize

Here's a sample TestCafe test script that demonstrates working with window resize:

import { Selector } from 'testcafe'; fixture('Window Resize Test') .page('https://www.example.com'); test('Resize Window', async t => { // Resize the window to a specific width and height await t.resizeWindow(800, 600); // Perform actions or assertions after window resize });

In this test:

  • We import the Selector function from TestCafe to select elements on the web page.
  • We define a fixture named 'Window Resize Test' and set the page to 'https://www.example.com'.
  • Inside the test function:
    • We use TestCafe's resizeWindow action to resize the browser window to a specific width and height (800x600 pixels in this example).
    • You can perform actions or assertions after the window resize as needed.

TestCafe will resize the browser window before executing any subsequent actions or assertions in the test. This can be useful for testing responsive design or verifying how the layout of a webpage adapts to different screen sizes.

Make sure to replace 'https://www.example.com' with the URL of the website you want to test. You can adjust the width and height values passed to resizeWindow according to your testing requirements.


    Leave a Comment


  • captcha text