[Feature] Add isAttached or isExisting to element
See original GitHub issueSummary
Implement an easy way to check whether an element is attached to the DOM.
test('test', async ({ page }) => {
const isExisting = await page.locator('body').isExisting() // returns true or false
})
It’s really not convenient to do something like this every time
const els = await page.locator('body').elementHandles()
const isExisting = els.length > 0
Existing functionality
Please don’t suggest waiters (wait for state to be attached/not attached, etc), visibility checks (isVisible, isHidden) or similar. This is completely different requests. Thank you
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:8 (1 by maintainers)
Top Results From Across the Web
isExisting - WebdriverIO
Returns true if element exists in the DOM. ... As opposed to other element commands WebdriverIO will not wait for the element to...
Read more >How to check whether dynamically attached event listener ...
Step 1: First, you will need a function that can traverse the storage object and return the record of an element given the...
Read more >How To Use Deep Selectors In Selenium WebdriverIO
This blog deep-dives into learning deep selectors in Selenium WebdriverIO and how to use them while writing tests for Selenium automation ...
Read more >Everett's harborfront public access capital improvement plan
New maritime planning concepts and individual public access features were ... the element is existing, will be improved or is a proposed new...
Read more >Learn Webdriver IO - STARTER EDITION - Part 1
There are a variety of ways we can tell WebdriverIO what element we want. ... Services are used to add extra functionality our...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was also looking for a simple way to assert element presence
I guess we could do:
but it seems like a very common assertion so maybe having
toExist()
/toBeInTheDocument()
/toBePresent()
is worth it:BTW @grybykm locator.waitFor() might be helpful in your case:
It would be also nice to have an assertion for this. Something like this: