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

dragAndDrop(draggedElementSelector, draggedOnElementSelector [,options])

Drags and drops on the given element onto another element on the page using HTML5 drag and drop events.

  • draggedElementSelector {string | TDKStepLocator} a CSS selector or smart locator for the element being dragged.
  • draggedOnElementSelector {string | TDKStepLocator} a CSS selector or smart locator for the element being dragged onto.
  • options {object} optional extra arguments for dragAndDrop. Currently none supported
  • returns: Promise which fulfills when the drag and drop has been executed.
// ✅ drags the active item to the item done list
await dragAndDrop('.item:active', '.done-item-list');
// ✅ drops the user picture on the gallery
await dragAndDrop('.user-picture', '.gallery');

// ❌needs to know where to drop the element
await dragAndDrop('.user-picture');
// ❌needs to know what to drop where
await dragAndDrop();

Full usage example:

'use strict';

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


it("performs drag and drop correctly", async () => {
    await go('http://jsbin.testim.io/put/2');
    await dragAndDrop('#drag1', '#div1');

    const innerHtml = await evaluate(() => {
        return document.querySelector('#div1').innerHTML;
    });

    
    expect(innerHtml).to.contain('img');
    expect(innerHtml).to.contain('id="drag1"');
    expect(innerHtml).to.contain('src="https://www.testim.io/images/social/logo_1200x1200.jpg"');

});

Updated 26 days ago

dragAndDrop(draggedElementSelector, draggedOnElementSelector [,options])


Suggested Edits are limited on API Reference Pages

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