aahashemi / YouTubeAutomation-Reddit

GNU General Public License v3.0
213 stars 56 forks source link

Timeout Error: waiting for locator("[data-test-id=\"post-content\"]") #12

Open Quincy475 opened 1 year ago

Quincy475 commented 1 year ago

Hi, ty for the script however i'm runnning into an error. Does anyone know how to fix?

Starting ..........
Logged in to Reddit successfully!
Chosen thread: What makes you not want to be intimate with your SO? -- Score: 11762
10 comments are chosen
Launching Headless Browser...
Traceback (most recent call last):
  File "C:\Users\quinc\YouTubeAutomation-Reddit\main.py", line 110, in <module>
    main()
  File "C:\Users\quinc\YouTubeAutomation-Reddit\main.py", line 35, in main
    get_screenshots_of_reddit_posts(reddit_thread=thread, reddit_comments=comments, screenshot_num=1)
  File "C:\Users\quinc\YouTubeAutomation-Reddit\Graphics\screenshot.py", line 60, in get_screenshots_of_reddit_posts
    page.locator(f'[data-test-id="post-content"]').screenshot(path=postcontentpath)
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\sync_api\_generated.py", line 16445, in screenshot
    self._sync(
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_sync_base.py", line 104, in _sync
    return task.result()
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_locator.py", line 479, in screenshot
    return await self._with_element(
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_locator.py", line 101, in _with_element
    handle = await self.element_handle(timeout=timeout)
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_locator.py", line 285, in element_handle
    handle = await self._frame.wait_for_selector(
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_frame.py", line 322, in wait_for_selector
    await self._channel.send("waitForSelector", locals_to_params(locals()))
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_connection.py", line 44, in send
    return await self._connection.wrap_api_call(
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_connection.py", line 419, in wrap_api_call
    return await cb()
  File "C:\Users\quinc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\_impl\_connection.py", line 79, in inner_send
    result = next(iter(done)).result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for locator("[data-test-id=\"post-content\"]")
============================================================
arch1904 commented 1 year ago

Were you able to find a fix? I'm having the same error and cant seem to find an answer

lilhiggy commented 1 year ago

Has anyone found a way to fix this?

Niconord59 commented 1 year ago

i've got the same error

IBangedMyToaster commented 1 year ago

Same error over here

tekmunki commented 1 year ago

I fixed this by setting new reddit as my default on the Reddit account preferences. If you have old reddit theme as default it causes this error.

IBangedMyToaster commented 1 year ago

I fixed this by setting new reddit as my default on the Reddit account preferences. If you have old reddit theme as default it causes this error.

Hey tekmunki, i tryed your fix but it doesnt seem to work since i didnt have old reddit enabled to beginn with, i even checked it out with a freshly created reddit account but i still get the same error.

marcozetaa commented 1 year ago

Did you guys figured it out? I am also struggling finding a solution to this problem

fazla043264 commented 1 year ago

Having the same issue. Any update will be really helpful.

RokuX9 commented 1 year ago

Hey, I fixed the problem you can check my pull request for the solution

15

amitozdeol commented 11 months ago

Since reddit changes it's HTML content when user is not logged in you also need to change how you are accessing the element. Before page.locator(f'[data-test-id="post-content"]')

After page.locator('shreddit-post')