find function lacks options parameter
See original GitHub issueCurrent behavior
It’s well written here that the find
function has 2 arguments: https://docs.cypress.io/api/commands/find#Arguments
But in my case, the function has only one argument (the selector
).
I am trying to use the timeout functionality with the find
function but it does not wait for the timeout.
Desired behavior
I expect that the find
function accepts the second argument as described in the documentation and similar to the get
function.
Test code to reproduce
body.find('.find-this-tag', { timeout: 10000 })
Cypress Version
9.5.2
Other
Thank you!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to get function parameter names/values dynamically?
The following function will return an array of the parameter names of any function passed in. var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?
Read more >Using Python Optional Arguments When Defining Functions
In this section, you'll learn how to define a function that takes an optional argument. Functions with optional arguments offer more flexibility in...
Read more >about Functions Advanced Parameters - PowerShell
If a function has no positional parameters, PowerShell assigns positions to each parameter based on the order the parameters are declared.
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >How To Use ES6 Arguments And Parameters
This function expects two arguments, but when it is called without arguments, it will use the default values. Inside the function, missing ...
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 FreeTop 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
Top GitHub Comments
Ah I see! Thanks for providing the example you were working with.
cy.get()
will yield the DOM element(s) found, which can be returned as an JQuery element. In the example you provided, you are trying to use JQuery’s find method instead of the.find()
Cypress command. I suggest updating your test to be something like this:This will look for you selector for the given timeout and if it does not exist your test will fail.
If you are trying to mitigate the test failures, you can listen to the
fail
Cypress event to determine the best way to handle this, however we do not necessarily recommend this approach beyond debugging. Docs for catching test failures.Give it a shot! However I do think this issue can be closed.
This is what I try to achieve: I have a non-deterministic case for my application and I want to test a specific part of the application only in a certain case. To achieve this I use the
find
function. As I said, the problem is that the function doesn’t wait for the element to be shown as the timeout option is provided but it yields the result instantly (which ofc is that it doesn’t exist because it depends on other parts of the app).If I go to the method’s declaration, I will be taken to the same definition as the functionality is: one parameter function
JQuery.d.ts - line 4136
find(selector_element: JQuery.Selector | Element | JQuery): this;