Drag and Drop

Pratique testes de arrastar e soltar elementos. Esta página é ideal para testar automação de drag & drop, validação de elementos arrastáveis, zonas de soltura e interações complexas de mouse.

Sobre esta Seção

Atividades do Dia a Dia:

  • Testar arrastar elementos de uma posição para outra
  • Validar zonas de soltura (drop zones)
  • Praticar automação de drag & drop em diferentes frameworks
  • Testar múltiplos elementos arrastáveis
  • Validar feedback visual durante o arraste
  • Testar eventos de hover, double click e right click
  • Validar estados antes e depois do drop

Como Utilizar:

  1. Arraste o elemento "Arraste-me" até a zona de soltura
  2. Observe o feedback visual durante o arraste
  3. Solte o elemento na zona de soltura
  4. Valide que o drop foi detectado corretamente
  5. Teste também hover, double click e right click nos outros elementos
  6. Use os data-testid para criar testes automatizados

Drag & Drop

Arraste o elemento arrastável até a zona de soltura.

Arraste-me
→
Solte aqui

Nenhum item foi solto ainda...

Outras Interações

Teste também hover, double click e right click.

Passe o mouse aqui
Dê dois cliques aqui
Clique com o botão direito

Informações para Testes

Cenários de Teste:

  • Arrastar elemento de origem para zona de soltura
  • Validar que drop foi detectado corretamente
  • Testar feedback visual durante o arraste
  • Validar estados antes e depois do drop
  • Testar hover, double click e right click
  • Validar múltiplos elementos arrastáveis

Elementos identificáveis:

  • data-testid="item-arrastavel" - Elemento arrastável
  • data-testid="zona-soltura" - Zona de soltura
  • data-testid="drop-text" - Texto da zona de soltura
  • data-testid="drop-status" - Status do drop
  • data-testid="box-hover" - Caixa de hover
  • data-testid="box-double-click" - Caixa de double click
  • data-testid="box-right-click" - Caixa de right click

Exemplos de Teste Automatizado:


// Cypress - Testar drag and drop
cy.get('[data-testid="item-arrastavel"]').trigger('mousedown', { which: 1 })
cy.get('[data-testid="zona-soltura"]').trigger('mousemove').trigger('mouseup')
cy.get('[data-testid="drop-text"]').should('contain', 'Item solto')
cy.get('[data-testid="drop-status"]').should('contain', 'Drop detectado')

// Testar hover
cy.get('[data-testid="box-hover"]').trigger('mouseover')
cy.get('[data-testid="hover-status"]').should('contain', 'Mouse sobre')

// Testar double click
cy.get('[data-testid="box-double-click"]').dblclick()
cy.get('[data-testid="dbl-status"]').should('contain', 'Double click')
                

// Playwright - Testar drag and drop
await page.getByTestId('item-arrastavel').dragTo(page.getByTestId('zona-soltura'))
await expect(page.getByTestId('drop-text')).toContainText('Item solto')
await expect(page.getByTestId('drop-status')).toContainText('Drop detectado')

// Testar hover
await page.getByTestId('box-hover').hover()
await expect(page.getByTestId('hover-status')).toContainText('Mouse sobre')

// Testar double click
await page.getByTestId('box-double-click').dblclick()
await expect(page.getByTestId('dbl-status')).toContainText('Double click')
                

// Selenium Java - Testar drag and drop
WebElement source = driver.findElement(By.cssSelector("[data-testid='item-arrastavel']"));
WebElement target = driver.findElement(By.cssSelector("[data-testid='zona-soltura']"));
Actions actions = new Actions(driver);
actions.dragAndDrop(source, target).perform();
WebElement dropText = driver.findElement(By.cssSelector("[data-testid='drop-text']"));
assert dropText.getText().contains("Item solto");

// Testar hover
WebElement hoverBox = driver.findElement(By.cssSelector("[data-testid='box-hover']"));
actions.moveToElement(hoverBox).perform();
WebElement hoverStatus = driver.findElement(By.cssSelector("[data-testid='hover-status']"));
assert hoverStatus.getText().contains("Mouse sobre");

// Testar double click
WebElement dblBox = driver.findElement(By.cssSelector("[data-testid='box-double-click']"));
actions.doubleClick(dblBox).perform();
                

# Capybara (Ruby) - Testar drag and drop
source = find('[data-testid="item-arrastavel"]')
target = find('[data-testid="zona-soltura"]')
source.drag_to(target)
expect(find('[data-testid="drop-text"]')).to have_content('Item solto')
expect(find('[data-testid="drop-status"]')).to have_content('Drop detectado')

# Testar hover
find('[data-testid="box-hover"]').hover
expect(find('[data-testid="hover-status"]')).to have_content('Mouse sobre')

# Testar double click
find('[data-testid="box-double-click"]').double_click
expect(find('[data-testid="dbl-status"]')).to have_content('Double click')
                

*** Test Cases ***
Testar drag and drop
    Drag And Drop    css:[data-testid="item-arrastavel"]    css:[data-testid="zona-soltura"]
    Element Should Contain    css:[data-testid="drop-text"]    Item solto
    Element Should Contain    css:[data-testid="drop-status"]    Drop detectado

Testar hover
    Mouse Over    css:[data-testid="box-hover"]
    Element Should Contain    css:[data-testid="hover-status"]    Mouse sobre

Testar double click
    Double Click Element    css:[data-testid="box-double-click"]
    Element Should Contain    css:[data-testid="dbl-status"]    Double click
                
← Voltar para Início