Use Cypress Element Alias To Avoid The Element Detached From DOM Error

preview_player
Показать описание
In this example, I show how to store the result of the long chain of Cypress commands in an alias.

.find('#items')
.find('li')
.first()
.as('fruit')

We can now get the element and add assertions to it

If the element becomes detached from the page DOM (because the application has re-rendered that part of the page), the Cypress Test Runner re-queries the commands in the chain that leads to the alias, refreshing the elements from the page.

Рекомендации по теме
Комментарии
Автор

Are you using Debugger for Chrome(deprecated) or some other plugin or extension to enable this concurrent debugging with Chrome in VSCode? It is very cool!

jingwenwang
Автор

I often have similar problem running tests on CI, locally problem does not exist :/

rwojciechowski
Автор

Hey Gleb, Can you please help with my scenario. I am trying to click on dropdown and then selecting the value from it. Script works perfectly fine when executed individually but fails when executed as a suite.

DD-tycp
Автор

How are you doing this By typing both application and cypress code in md file, plz give me reference for this

simbolla
Автор

I wish cypress could handle it under the hood

romankhomitskyi