[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:
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](https://private-user-images.githubusercontent.com/70666681/307236259-09b328e2-963f-424a-811f-bf4ce3208e8e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTA4ODY1OTgsIm5iZiI6MTcxMDg4NjI5OCwicGF0aCI6Ii83MDY2NjY4MS8zMDcyMzYyNTktMDliMzI4ZTItOTYzZi00MjRhLTgxMWYtYmY0Y2UzMjA4ZThlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzE5VDIyMTEzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkyOGJiNGFkOTM3OTA5NzNmNjc4ZmFlOWFkODcxYmFiMWUyMzZlNjg4NDJlZjBkYTgwMjU2NTUwZjA4ZTI1OTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7jSyiWoP55QzspdQd9T3A7F-Utr3psmritCU92FTLqY)
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](https://private-user-images.githubusercontent.com/70666681/307427723-8d74f70a-6877-481f-8d59-b1853805f072.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTA4ODY1OTgsIm5iZiI6MTcxMDg4NjI5OCwicGF0aCI6Ii83MDY2NjY4MS8zMDc0Mjc3MjMtOGQ3NGY3MGEtNjg3Ny00ODFmLThkNTktYjE4NTM4MDVmMDcyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzE5VDIyMTEzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUxNjk5ZmUxNTcwNTJmZmJkZTk3OWNkMTk3NjJmOTE3MTYxMDFkMzQ0YTFiZjNiMjBjNWQzYjc3MGYwZjc1ODcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.6SJDdl4hpdFI2HyS2c9v-haQSexsJzz3BL2V91reRqw)
![Screen Shot 2024-02-23 at 11 14 19 AM](https://private-user-images.githubusercontent.com/70666681/307427838-1896b2dc-78ff-4a14-8ea3-6ca9346e9550.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTA4ODY1OTgsIm5iZiI6MTcxMDg4NjI5OCwicGF0aCI6Ii83MDY2NjY4MS8zMDc0Mjc4MzgtMTg5NmIyZGMtNzhmZi00YTE0LThlYTMtNmNhOTM0NmU5NTUwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzE5VDIyMTEzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM4YTBhZjQ3MWRkNzViNjM5YWZiNjYxZThmMDA1ZjRlOTA5YjVjZjBlMWMyZTRmZWM4ODRiZWVhMGY2MWMwY2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.KTvCkuwDbfyJ6zBLKPEVDZR7sk7uoB_JUyXknbcRUdo)
@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.![]()
![]()
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.