playwright-java
playwright-java copied to clipboard
[BUG] Object doesn't exist.
Context:
- Playwright Version: 1.23.0
- Operating System: Windows 10
- Browser: Chromium
- Extra: jdk-18.0.1.1 with Graddle.
Code Snippet
page3.locator("#reference").fill(title1);
page3.locator("#reference").press("Enter");
Describe the bug What happens is that sometimes playwright does not detect elements and jumps the error, the element are correct since I check it whenever an error of this kind occurs.
I'm trying to figure out some way to handle this situation when it happens, maybe by asking playwright to check that all the locators exist before it does the process, and if they don't exist retry again.
Would that solve my problem?, how can I detect if a page.locator exists?
Thanks!
What happens is that sometimes playwright does not detect elements and jumps the error, the element are correct since I check it whenever an error of this kind occurs.
What is the error that you see? Playwright will automatically wait for the element to be on the page until certain timeout (30s by default). Can you share an example which we can run locally?
I'm trying to figure out some way to handle this situation when it happens, maybe by asking playwright to check that all the locators exist before it does the process, and if they don't exist retry again.
You can use locatot.isVisible() to check if the element is present on the page without waiting but that is unlikely what you want, default auto-waiting should work for you.
What happens is that sometimes playwright does not detect elements and jumps the error, the element are correct since I check it whenever an error of this kind occurs.
What is the error that you see? Playwright will automatically wait for the element to be on the page until certain timeout (30s by default). Can you share an example which we can run locally?
Hello,
I will try to reproduce the error, but as it appears randomly I don't have an estimated time, as soon as I get the error I will post it
Thanks for helping :)
What is the error that you see? Playwright will automatically wait for the element to be on the page until certain timeout (30s by default). Can you share an example which we can run locally?
Hi, this is the error I get for no reason, it appears randomly 5-10 minutes after running the app, the locator is correct.
name='TimeoutError`
stack='TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "xpath=/html/body/span/span/span[1]/input"
============================================================
at ProgressController.run (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\progress.js:96:26)
at Frame.fill (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\frames.js:1203:23)
at FrameDispatcher.fill (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\dispatchers\frameDispatcher.js:189:30)
at DispatcherConnection.dispatch (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\dispatchers\dispatcher.js:352:46)
}
at com.microsoft.playwright.impl.WaitableResult.get(WaitableResult.java:52)
at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:103)
at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:106)
at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:94)
at com.microsoft.playwright.impl.FrameImpl.fillImpl(FrameImpl.java:338)
at com.microsoft.playwright.impl.FrameImpl.lambda$fill$15(FrameImpl.java:328)
at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
at com.microsoft.playwright.impl.ChannelOwner.withLogging(ChannelOwner.java:79)
at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
at com.microsoft.playwright.impl.FrameImpl.fill(FrameImpl.java:328)
at com.microsoft.playwright.impl.LocatorImpl.fill(LocatorImpl.java:202)
at com.microsoft.playwright.Locator.fill(Locator.java:2108)
at com.warehousebot.restock.Main.main(Main.java:109)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.microsoft.playwright.TimeoutError: Error {
message='Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "xpath=/html/body/span/span/span[1]/input"
============================================================
name='TimeoutError
stack='TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "xpath=/html/body/span/span/span[1]/input"
============================================================
at ProgressController.run (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\progress.js:96:26)
at Frame.fill (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\frames.js:1203:23)
at FrameDispatcher.fill (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\dispatchers\frameDispatcher.js:189:30)
at DispatcherConnection.dispatch (C:\Users\nicol\AppData\Local\Temp\playwright-java-11656587265342251811\package\lib\server\dispatchers\dispatcher.js:352:46)
}
at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:186)
at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:168)
at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:101)
... 13 more
Caused by: com.microsoft.playwright.TimeoutError: Error {
Also I just have got this error too (the locator is correct too):
Exception in thread "Thread-3" com.microsoft.playwright.PlaywrightException: Object doesn't exist: response@1592da083cdde1ade23c46337230bf79
at com.microsoft.playwright.impl.Connection.getExistingObject(Connection.java:149)
at com.microsoft.playwright.impl.BrowserContextImpl.handleEvent(BrowserContextImpl.java:609)
at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:214)
at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:168)
at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:101)
at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:106)
at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:94)
at com.microsoft.playwright.impl.FrameImpl.clickImpl(FrameImpl.java:255)
at com.microsoft.playwright.impl.FrameImpl.lambda$click$9(FrameImpl.java:246)
at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36)
at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
at com.microsoft.playwright.impl.ChannelOwner.withLogging(ChannelOwner.java:79)
at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
at com.microsoft.playwright.impl.FrameImpl.click(FrameImpl.java:246)
at com.microsoft.playwright.impl.LocatorImpl.click(LocatorImpl.java:132)
at com.microsoft.playwright.Locator.click(Locator.java:1731)
at com.warehousebot.restock.Main.main(Main.java:136)
at java.base/java.lang.Thread.run(Thread.java:833)
name='TimeoutError` stack='TimeoutError: Timeout 30000ms exceeded. =========================== logs =========================== waiting for selector "xpath=/html/body/span/span/span[1]/input" ============================================================
There is no element with such selector. Use tracing to debug this issue and see how the DOM tree looks like when the operation fails.
Also I just have got this error too (the locator is correct too): Exception in thread "Thread-3" com.microsoft.playwright.PlaywrightException: Object doesn't exist: response@1592da083cdde1ade23c46337230bf79
This looks like a bug in Playwright, we'll need a reproducible example to understand what's going on a fix it. Could you share one that we could run locally?
+1 to this issue. Something similar is happening at my end. The issue is with parallel execution. Some threads intermittently produce Object doesn't exist as described above. When we run it in a single thread everything works perfectly fine.
I am creating a new BrowserContext in hooks (Before) and then setting it up in Cucumber Context (which is managed for parallel runs out of the box) and then finally closing it in hooks (After). No action is being performed once the page is closed. I have tried using traces but the issue as stated is pretty intermittent in nature and has something to do with parallel executions.
+1 to this issue. Something similar is happening at my end. The issue is with parallel execution. Some threads intermittently produce Object doesn't exist as described above. When we run it in a single thread everything works perfectly fine.
This is a different issue I believe, it sounds more like a synchronization issue in the client code, the tracing will not help you there, you need to ensure that the same playwright instance is not used concurrently on multiple threads.
+1 to this issue. Something similar is happening at my end. The issue is with parallel execution. Some threads intermittently produce Object doesn't exist as described above. When we run it in a single thread everything works perfectly fine.
This is a different issue I believe, it sounds more like a synchronization issue in the client code, the tracing will not help you there, you need to ensure that the same playwright instance is not used concurrently on multiple threads.
Hey that's exactly what I was doing, so I have a question: How I am suppose to run other Pages in the same instance without launching them with other thread? With a call method? Isn't there other way?
Thanks!
Hey that's exactly what I was doing, so I have a question: How I am suppose to run other Pages in the same instance without launching them with other thread? With a call method? Isn't there other way?
See this guide: https://playwright.dev/java/docs/multithreading Since playwright java uses synchronous API there is a natural limitation that you cannot easily send many commands to the same page. You can send commands to the pages sequentially though.
Closing as part of the triage process. Please create a new issue with a detailed reproducible or feature request if you still face issues.