elebumm / RedditVideoMakerBot

Create Reddit Videos with just✨ one command ✨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: waiting for locator("[name="username"]")

planted101 opened this issue · comments

Describe the bug

There is an issue logging into Reddit due to Reddit transitioning to their new UI (I think).

You can view the different login UIs here:

image image

New Login Page (LEFT) is the one that raises an error within the bot. This is caused by multiple instances that contain [name="username"], [name="password"], and the button is also different. Old login page (RIGHT) is the one that the current bot is compatible with.

Reproduction Steps

running main.py, as usual. The bug appears only when reddit.com/login loads with the new login page, which happens sporadically.

I'm not sure if it will work with everyone, but you can try viewing the different login pages outside of the code with different browsers. Pasting reddit.com/login in Chrome Incognito shows the new login page. Pasting the same link into safari or non-incognito chrome shows the old login page

Expected behavior

Successfully logging into Reddit Account.

Screenshots

image

System Information

Operating System : Mac OS Monterey
Python version : 3.10
App version / Branch : latest/master

Checklist

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

Additional Context

I have a current workaround, but figured I might as well let the developers know in case they may have a better solution:

        #Added by Planted101 -- Specify Reddit locator for new login page
        input_user = 'input[name="username"][type="text"][required]'
        input_pass = 'input#login-password[type="password"][required]'
        button_locator = 'button.login.w-100.button-large.button-brand'

        try:
            # Try initial locators and actions
            page.locator(input_user).fill(settings.config["reddit"]["creds"]["username"])
            page.locator(input_pass).fill(settings.config["reddit"]["creds"]["password"])
            page.locator(button_locator).click()
        except playwright._impl._api_types.Error:
            # If initial locators and actions fail, try alternative locators and actions
            print("Initial locators and actions failed, trying alternatives...")
            page.locator('[name="username"]').fill(settings.config["reddit"]["creds"]["username"])
            page.locator('[name="password"]').fill(settings.config["reddit"]["creds"]["password"])
            page.locator("button[class$='m-full-width']").click()

Note: There are still parts that error after the login as well, probably also caused by the UI change.
ie. waiting for locator("[data-test-id="post-content"]")

This was partially fixed by #1960 -- if you're also stuck, copy the changes accordingly

Ongoing Issues:

  • final_video.py is trying to access screenshots that don't exist. Problem did not occur before UI change.

Fixed:

  • After screenshotting 9th comment, Reddit crashes. -- just added a condition
    if 'Oops, something went wrong, please try again later.' in page.content(): # Refresh the page page.reload() # Retry the code after refreshing the page continue

@planted101 please see if the current version of #1960 works for you. If so, I'll merge into main.

@JasonLovesDoggo Thanks for the update -- I fixed it after adding a condition that if a crash message is seen, reload the page, but I'm facing a different problem now.

Somewhere after print_step("Rendering the video 🎥") in final_video.py, the code is trying to find comments that do not exist. I'm looking into it at the moment. Problem did not occur before UI change.

Screen Shot 2024-02-23 at 11 13 41 AM Screen Shot 2024-02-23 at 11 14 19 AM

#1960

@JasonLovesDoggo Thanks for the update -- I fixed it after adding a condition that if a crash message is seen, reload the page, but I'm facing a different problem now.

Somewhere after print_step("Rendering the video 🎥") in final_video.py, the code is trying to find comments that do not exist. I'm looking into it at the moment. Problem did not occur before UI change.

Screen Shot 2024-02-23 at 11 13 41 AM Screen Shot 2024-02-23 at 11 14 19 AM

#1960

Got it, since you seem to be familiar with programming, if you give me or that pr author a valid fix, I'll be happy to merge that too.

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.

Issue closed due to being stale. Please reopen if issue persists in latest version.