-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WaitFor fails for web element #4522
Comments
Is there any other method to wait for element till it exist? Or can this be fixed for web view elements, to work as well with waitfor() ? |
Hey @alexandravychytill, unfortunately there's no wait-for API for Web elements in Detox, this is not valid API usage (however.. contributions are welcome!) |
@alexandravychytill - You may use such function, to wait for web elements. I use such and work pretty fine for me: static async pause(value: number = 30000) {
return new Promise(resolve => {
setTimeout(resolve, value)
})
} private async waitForWebElement(webElement: Detox.IndexableMaybeSecuredWebElement & Detox.SecuredWebElementFacade, maxWaitTime = 30000) {
const startTime = Date.now()
while (Date.now() - startTime < maxWaitTime) {
try {
await expect(webElement).toExist()
await Helper.pause(1000)
return
} catch (error) {
if (Date.now() - startTime >= maxWaitTime) {
throw error
}
await Helper.pause(100)
}
}
} const loginInput = web.element(by.web.id('Login'))
await this.waitForWebElement(loginInput) |
Hello! We appreciate you bringing this issue to our attention. If you're interested in contributing to this feature, You're also welcome to join our Discord server Please feel free to reach out to us if you have any questions, or need help with anything. |
What happened?
await waitFor(web.element(by.web.xpath("//a[@Class='pcc-client-content-feed__panel-wrapper-title-link' and contains(text(), 'Following')]"))).toBeVisible().withTimeout(5000);
--> [object Object] is not a Detox matcher. More about Detox matchers here: https://wix.github.io/Detox/docs/api/matchers
What was the expected behaviour?
Waiter function should work and not through bug
Was it tested on latest Detox?
Did your test throw out a timeout?
Help us reproduce this issue!
No response
In what environment did this happen?
Detox version: 20.20.1
React Native version: 0.72.0
Has Fabric (React Native's new rendering system) enabled: yes
Node version: >=16
Device model: iPhone 15
iOS version: 17.2
macOS version: 14.4
Xcode version: 15.2
Test-runner (select one): jest
Detox logs
Detox logs
Device logs
Device logs
More data, please!
No response
The text was updated successfully, but these errors were encountered: