RedditVideoMakerBot icon indicating copy to clipboard operation
RedditVideoMakerBot copied to clipboard

[Bug]: Playwright timeout 3000ms

Open Johndunking opened this issue 3 years ago • 12 comments

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

  • [X] I have searched the open issues for duplicates.
  • [X] 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?

Johndunking avatar Apr 27 '23 01:04 Johndunking

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!

xyba1337 avatar May 03 '23 19:05 xyba1337

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!

Johndunking avatar May 05 '23 01:05 Johndunking

?

Johndunking avatar May 05 '23 01:05 Johndunking

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

theduckbusiness avatar May 09 '23 00:05 theduckbusiness

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)

superfonz avatar May 10 '23 01:05 superfonz

Hmmm I made that replacement but I am still receiving the playwright error. After logging into reddit the program freezes. Any other suggestions? Program used to run sometimes but now it fails every time.

On Tue, May 9, 2023 at 6:37 PM superfonz @.***> wrote:

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)

— Reply to this email directly, view it on GitHub https://github.com/elebumm/RedditVideoMakerBot/issues/1596#issuecomment-1541163249, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7OMURW3FRJEFVJCOGELWRTXFLWNJANCNFSM6AAAAAAXNFFSUI . You are receiving this because you authored the thread.Message ID: @.***>

Johndunking avatar May 10 '23 04:05 Johndunking

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")

Isma27K avatar May 11 '23 07:05 Isma27K

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.

steferic avatar May 11 '23 21:05 steferic

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

Johndunking avatar May 12 '23 19:05 Johndunking

@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.

liamb13 avatar May 13 '23 01:05 liamb13

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!

Johndunking avatar May 13 '23 19:05 Johndunking

Hey. I still dont understand how to change the ui

eimuzas avatar Jan 26 '24 23:01 eimuzas