Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SeleniumBase Solves CAPTCHA Once, But Fails on Second Attempt on Login Page #3233

Answered by mdmintz
sibghatullah78 asked this question in Q&A
Discussion options

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

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
5 replies
Comment options

Upgrade to 4.32.5 (or newer if available)

Comment options

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!

Comment options

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

Comment options

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()
Comment options

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!

Screenshot from 2024年10月29日 13-56-20

Comment options

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)
You must be logged in to vote
1 reply
Comment options

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

Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /