Skip to content

[Bug]: Playwright timeout 3000ms #1596

Closed

Description

@Johndunking

Describe the bug

Launching Headless Browser...
Logging in to Reddit...
Skipping translation...
Something went wrong!
Something went wrong with making the screenshots! Do you want to skip the post? (y/n) n
Do you want the error traceback for debugging purposes? (y/n)y
╭────────────────────────────────────────────────╮
│ Sorry, something went wrong with this version! │
│ Try again, and feel free to report this issue │
│ at GitHub or the Discord community. │
│ Version: 3.1 │
│ Error: Timeout 30000ms exceeded. │
│ =========================== logs │
│ =========================== │
│ waiting for │
│ locator("[data-test-id="post-content"]") │
│ ============================================== │
│ ============== │
│ Config: {'allow_nsfw': False, 'theme': │
│ 'light', 'times_to_run': 1, 'opacity': 0.9, │
│ 'transition': 0.2, 'storymode': False, │
│ 'storymodemethod': 1, 'storymode_max_length': │
│ 1000, 'resolution_w': 1080, 'resolution_h': │
│ 1920, 'background': {'background_choice': │
│ 'minecraft', 'background_thumbnail': False, │
│ 'background_thumbnail_font_family': 'arial', │
│ 'background_thumbnail_font_size': 96, │
│ 'background_thumbnail_font_color': │
│ '255,255,255'}, 'tts': {'voice_choice': │
│ 'streamlabspolly', 'aws_polly_voice': │
│ 'Matthew', 'streamlabs_polly_voice': │
│ 'Matthew', 'tiktok_voice': 'en_us_001', │
│ 'tiktok_sessionid': 'REDACTED', │
│ 'python_voice': '1', 'py_voice_num': '2', │
│ 'silence_duration': 0.3, 'no_emojis': False}} │
╰────────────────────────────────────────────────╯
Traceback (most recent call last):
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/main.py", line 130, in
raise err
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/main.py", line 111, in
run_many(config["settings"]["times_to_run"])
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/main.py", line 64, in run_many
main()
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/main.py", line 52, in main
get_screenshots_of_reddit_posts(reddit_object, number_of_comments)
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/video_creation/screenshot_downloader.py", line 183, in get_screenshots_of_reddit_posts
raise e
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/video_creation/screenshot_downloader.py", line 161, in get_screenshots_of_reddit_posts
page.locator('[data-test-id="post-content"]').screenshot(
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 17227, in screenshot
self._sync(
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 104, in _sync
return task.result()
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 491, in screenshot
return await self._with_element(
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 103, in _with_element
handle = await self.element_handle(timeout=timeout)
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 297, in element_handle
handle = await self._frame.wait_for_selector(
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_frame.py", line 322, in wait_for_selector
await self._channel.send("waitForSelector", locals_to_params(locals()))
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 61, in send
return await self._connection.wrap_api_call(
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 461, in wrap_api_call
return await cb()
File "/Users/johnduncan/Downloads/RedditVideoMakerBot-master/myvenv/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 96, 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"]")

Reproduction Steps

Ran the bot with nsfw set to false. This used to only happen sometimes but now it happens all the time.

Expected behavior

download screenshots.

Screenshots

No response

System Information

Operating System :Mac
Python version : 3.10.6
App version / Branch : latest

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.

Additional Context

I've tried a lot of fixes by searching GitHub and noticed that others have this same issue. Can anyone lead me in the direction of fixing this bug?

Activity

  1. added
    bug
    on Apr 27, 2023
  2. xyba1337 commented on May 3, 2023

    @xyba1337
    Contributor

    Hi!

    I was having the same issue and just resolved it. It turned out that the password for my Reddit account in the config.toml file was incorrect.

    To identify the problem, I navigated to /video_creation/screenshot_downloader.py and changed "headless" to "False" on line 85. This allowed me to view the browser window and debug the issue more effectively.
    The Playwright locator timed out because the browser failed to log me in to Reddit using the incorrect credentials, which prevented it from accessing the desired post.

    I hope this solution will be helpful to anyone else experiencing a similar problem!

  3. Johndunking commented on May 5, 2023

    @Johndunking
    Author

    Hi!

    I was having the same issue and just resolved it. It turned out that the password for my Reddit account in the config.toml file was incorrect.

    To identify the problem, I navigated to /video_creation/screenshot_downloader.py and changed "headless" to "False" on line 85. This allowed me to view the browser window and debug the issue more effectively. The Playwright locator timed out because the browser failed to log me in to Reddit using the incorrect credentials, which prevented it from accessing the desired post.

    I hope this solution will be helpful to anyone else experiencing a similar problem!

    Hmm thanks for the support but when I turned the headless browser off I can watch it log
    Me in then it freezes at the chosen subreddit. Any ideas!

  4. Johndunking commented on May 5, 2023

    @Johndunking
    Author

    ?

  5. theduckbusiness commented on May 9, 2023

    @theduckbusiness

    Did you solved it? I'm having the same problem :(

  6. superfonz commented on May 10, 2023

    @superfonz

    Hi the issue is because the playwright browser loads a different style of reddit (which means the img will look different) This is the fix.
    In the code go to video_creation>screenshot_downloader.py
    Around Line 82 replace page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) with this
    page.locator(f'[id="t3_{id}"]').screenshot(path=postcontentpath)

  7. Johndunking commented on May 10, 2023

    @Johndunking
    Author
  8. Isma27K commented on May 11, 2023

    @Isma27K

    File "C:\Users\binhe\OneDrive\Documents\REAL STUFF\work\no play\Youtube-video-bot-master\main.py", line 83, in
    run_many(config["settings"]["times_to_run"])
    File "C:\Users\binhe\OneDrive\Documents\REAL STUFF\work\no play\Youtube-video-bot-master\main.py", line 62, in run_many
    main()
    File "C:\Users\binhe\OneDrive\Documents\REAL STUFF\work\no play\Youtube-video-bot-master\main.py", line 50, in main
    download_screenshots_of_reddit_posts(reddit_object, number_of_comments)
    File "C:\Users\binhe\OneDrive\Documents\REAL STUFF\work\no play\Youtube-video-bot-master\video_creation\screenshot_downloader.py", line 109, in download_screenshots_of_reddit_posts
    page.locator(f"#t1_{comment['comment_id']}").screenshot(
    File "C:\Users\binhe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright\sync_api_generated.py", line 17370, in screenshot
    self._sync(
    File "C:\Users\binhe\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\binhe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright_impl_locator.py", line 521, in screenshot
    return await self._with_element(
    File "C:\Users\binhe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright_impl_locator.py", line 115, in _with_element
    handle = await self.element_handle(timeout=timeout)
    File "C:\Users\binhe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright_impl_locator.py", line 315, in element_handle
    handle = await self._frame.wait_for_selector(
    File "C:\Users\binhe\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\binhe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright_impl_connection.py", line 61, in send
    return await self._connection.wrap_api_call(
    File "C:\Users\binhe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright_impl_connection.py", line 461, in wrap_api_call
    return await cb()
    File "C:\Users\binhe\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playwright_impl_connection.py", line 96, in inner_send
    result = next(iter(done)).result()
    playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
    =========================== logs ===========================
    waiting for locator("#t1_jjnfdnh")

  9. steferic commented on May 11, 2023

    @steferic

    Had this issue and was able to resolve it. For me, the issue was that my account was configured to the old reddit UI. The code in the repo is meant to handle the new UI code, so if you don't switch to that you'll have to modify the code.

  10. Johndunking commented on May 12, 2023

    @Johndunking
    Author

    Thanks,
    I switched the UI as well and I am still getting the same error :( any other ideas?

  11. liamb13 commented on May 13, 2023

    @liamb13
    Contributor

    @Johndunking try adjusting the timeout values:

    https://github.com/elebumm/RedditVideoMakerBot/blob/master/video_creation/screenshot_downloader.py#L117-L124

    Best way to see what's happening is what @xyba1337 mentioned:

    To identify the problem, I navigated to /video_creation/screenshot_downloader.py and changed "headless" to "False" on line 85.

  12. Johndunking commented on May 13, 2023

    @Johndunking
    Author

    Thank you @liamb13 and @stefanlenoach the solution was to change my reddit UI but I couldn't tell the difference that made until I launched with headless browser again which then I realized the replacement I made from @superfonz was not working for my program so I corrected it to the original line and now the program is working! Thanks everyone.

    In short if you are having the same playwright issue I believe the solution is to set the reddit account you are using to the new UI ( go to your reddit account settings and select beta testing then the option to use the new UI will appear upon page refresh) and to not change any of the base program code. Hope that helps anyone who is still struggling. I just started programming this month so I apologize if my explanation is difficult to understand!

  13. eimuzas commented on Jan 26, 2024

    @eimuzas

    Hey. I still dont understand how to change the ui

  14. added a commit that references this issue on Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions