-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SeleniumBase Solves CAPTCHA Once, But Fails on Second Attempt on Login Page #3233
-
I'm using SeleniumBase with uc=True to interact with a site that has two CAPTCHAs during the login process. The first CAPTCHA is solved successfully using sb.uc_gui_click_captcha(), but on the second CAPTCHA, the solution doesn’t complete, and SeleniumBase fails to proceed. Here’s the code snippet:
from seleniumbase import SB
with SB(uc=True) as sb:
url = "https://agents.moderationinterface.com"
sb.uc_open_with_reconnect(url, 3)
sb.uc_gui_click_captcha()
sb.type('input[name="username"]', "NL_1952")
sb.type('input[name="password"]', "pa321345874565477")
# Solve the CAPTCHA if present
sb.uc_gui_click_captcha() # PyAutoGUI click (necessary on Linux)
sb.click("#login-submit")
sb.sleep(3)
Issue:
The script successfully solves the first CAPTCHA on the main login page.
The second CAPTCHA on the login form fails to resolve.
Questions:
Is there an approach in SeleniumBase to consistently solve multiple CAPTCHAs during the login flow?
Are there settings or methods that could help SeleniumBase to recognize and solve the CAPTCHA on the second attempt?
i am using ubuntu 22.04
below is the output screenshot
Screenshot from 2024年10月28日 10-46-52
Screenshot from 2024年10月28日 10-43-51
Beta Was this translation helpful? Give feedback.
All reactions
Use the new CDP Mode within UC Mode (with SeleniumBase 4.32.5
, or newer if available):
from seleniumbase import SB with SB(uc=True, test=True) as sb: url = "https://agents.moderationinterface.com" sb.activate_cdp_mode(url) sb.uc_gui_click_captcha() sb.sleep(2) sb.uc_gui_click_captcha() sb.sleep(2)
Replies: 2 comments 6 replies
-
I think I see the issue. The CAPTCHA section is right-aligned, changing the checkbox coordinates. I can add a fix in the next release. (Probably soon.) In the meantime, you can probably use uc_gui_click_x_y(x, y)
if you know the correct coordinates.
Beta Was this translation helpful? Give feedback.
All reactions
-
Upgrade to 4.32.5
(or newer if available)
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for responding so promptly!
I’ll try updating to version 4.32.5 and see if that resolves the issue with the second CAPTCHA. In the meantime, I'll experiment with uc_gui_click_x_y(x, y) to manually click the CAPTCHA coordinates.
I'll let you know whether this approach works or if I encounter any further issues. Thanks again for the guidance!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
I've updated to the latest version of SeleniumBase as you suggested. Yesterday, sb.uc_gui_click_captcha() wasn’t even clicking on the CAPTCHA, but today it’s aligning the CAPTCHA to the left and then successfully checking the checkbox. However, I’m still encountering an issue—the login page shows a Cloudflare error after the CAPTCHA is solved (screenshot attached). Any thoughts on how to troubleshoot this?
Screenshot from 2024年10月29日 07-40-20
Beta Was this translation helpful? Give feedback.
All reactions
-
This works for me:
from seleniumbase import SB with SB(uc=True, test=True) as sb: url = "https://agents.moderationinterface.com" sb.uc_open_with_reconnect(url) sb.uc_gui_click_captcha() sb.sleep(2) sb.uc_gui_click_captcha()
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for your assistance—I really appreciate it! Unfortunately, the script is still getting stuck on the second CAPTCHA. It successfully bypasses the first CAPTCHA as before, but when it reaches the second one, it fails to solve it. The output shows that the CAPTCHA is bypassed and the test passes, but in reality, it’s not solved. I’ve attached a screenshot of the output for reference.
When I run the script without xvfb on a regular display, I can clearly see that it doesn’t solve the second CAPTCHA, even though the output indicates success. Additionally, I tried modifying the script to use https://agents.moderationinterface.com/chat/index, which redirects to the login page. In this case, only one CAPTCHA is present, but SeleniumBase still fails to solve it.
Interestingly, the example solutions on SeleniumBase’s GitHub repository show successful CAPTCHA solving on form pages. I’m not sure why this issue is occurring specifically on my website.
Thank you again for your time, effort, and contributions to the community. Any guidance you could provide would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions
-
Use the new CDP Mode within UC Mode (with SeleniumBase 4.32.5
, or newer if available):
from seleniumbase import SB with SB(uc=True, test=True) as sb: url = "https://agents.moderationinterface.com" sb.activate_cdp_mode(url) sb.uc_gui_click_captcha() sb.sleep(2) sb.uc_gui_click_captcha() sb.sleep(2)
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes sir it worked with the CDP Mode thanks for helping the community we appreciate your efforts and dedication with the selenium base I am a software engineer I love the work you are doing for the selenium base I will also contribute to that. Once thank you sr
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1