Fix login inputs and button click

This fixes the selection of the username/password inputs and the submit button. Currently, with headless disabled this doesn't work.
pull/2024/head
MrRazamataz 1 year ago committed by GitHub
parent d1a3a23da2
commit 304056d3ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -73,7 +73,7 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
print_substep("Launching Headless Browser...") print_substep("Launching Headless Browser...")
browser = p.chromium.launch( browser = p.chromium.launch(
headless=True headless=False # currently, when this is enabled, the login process fails (reddit is cracking down on bots)
) # headless=False will show the browser for debugging purposes ) # headless=False will show the browser for debugging purposes
# Device scale factor (or dsf for short) allows us to increase the resolution of the screenshots # Device scale factor (or dsf for short) allows us to increase the resolution of the screenshots
# When the dsf is 1, the width of the screenshot is 600 pixels # When the dsf is 1, the width of the screenshot is 600 pixels
@ -98,9 +98,9 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int):
page.set_viewport_size(ViewportSize(width=1920, height=1080)) page.set_viewport_size(ViewportSize(width=1920, height=1080))
page.wait_for_load_state() page.wait_for_load_state()
page.locator('[name="username"]').fill(settings.config["reddit"]["creds"]["username"]) page.locator('[autocomplete="username"]').fill(settings.config["reddit"]["creds"]["username"])
page.locator('[name="password"]').fill(settings.config["reddit"]["creds"]["password"]) page.locator('[autocomplete="current-password"]').fill(settings.config["reddit"]["creds"]["password"])
page.locator("button[class$='m-full-width']").click() page.get_by_role("button", name="Log In").click()
page.wait_for_timeout(5000) page.wait_for_timeout(5000)
login_error_div = page.locator(".AnimatedForm__errorMessage").first login_error_div = page.locator(".AnimatedForm__errorMessage").first

Loading…
Cancel
Save