python-anticaptcha icon indicating copy to clipboard operation
python-anticaptcha copied to clipboard

Selenium not submitting form with anticaptcha

Open priteshthaker1501 opened this issue 5 years ago • 8 comments

@ad-m I really tried hard using your code with selenium and chrome. I want to login on https://services.aig.co.il/PersonalServices/#/login;url=%2Fhome

when I'm trying to login after some attempts there is Recaptcha and I have API_KEY and SITE_KEY. I got a token using website_url and site_key. but still, a successful login is not working.

api_key = "**********************"
client = AnticaptchaClient(api_key)


def get_token(website_url, site_key, invisible):
    task = NoCaptchaTaskProxylessTask(
        website_url=website_url,
        website_key=site_key,
        is_invisible=invisible
    )
    job = client.createTask(task)
    job.join()
    return job.get_solution_response()

I got token succesfull but I don't know what is not woking when i'm trying to submit form.

 site_key = "6LcJ8QgUAAAAAB_VRlbua73AhNAp7b6AVLw-cORX"
__SITE_HOME_PAGE_FOR_CRAWLING = 'https://services.aig.co.il/PersonalServices/#/login;url=%2Fhome'
 print("Found site-key", site_key)
 invisible_captcha = False
 token = get_token(__SITE_HOME_PAGE_FOR_CRAWLING, site_key, invisible_captcha)
 print("Found token", token)
 print("Received challenge-response")

 # Inject response in webpage
 current_user_driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % token)

 # submit form
 login_form = WebDriverWait(current_user_driver, 10).until(
            EC.presence_of_element_located((By.CLASS_NAME, "login__form")))
 submit_button = WebDriverWait(login_form, 10).until(
            EC.element_to_be_clickable((By.CLASS_NAME, "login__form__button")))
 submit_button.click()

priteshthaker1501 avatar Nov 19 '19 07:11 priteshthaker1501

Can you provide the correct values in the form? I tried to fill it in, but I can't figure out any ID because I don't know the system.

I write below notes in this area:

driver.get(site_url)
script = '''
    // Not always form captcha-protected
    if(document.getElementById("g-recaptcha-response")) {{
        document.getElementById("g-recaptcha-response").innerHTML = "{0}";
    }};
'''.format(token);
driver.execute_script(script)

driver.find_element(By.XPATH, '//input[@formcontrolname="custId"]').send_keys("??")
driver.find_element(By.XPATH, '//input[@formcontrolname="custPhone"]').send_keys(
    "0528880337"
)
driver.find_element(By.XPATH, '//input[@formcontrolname="custId"]').click()
WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.CLASS_NAME, "login__form"))
).click()
submit_button = WebDriverWait(login_form, 10).until(
    EC.element_to_be_clickable((By.CLASS_NAME, "login__form__button"))
).click()

ad-m avatar Nov 28 '19 01:11 ad-m

Closed due submitter inactivity. Feel free to write comment and ask to reopen if you have still that issue.

ad-m avatar Jan 11 '20 18:01 ad-m

Hey @ad-m! I've been trying to make it work on the website http://servicos.dnit.gov.br/multas/LogIn but without success...

I was able to get the sitekey and to find the .

However, I cannot make the form submit after I add the token to this textarea.

Do you have any clue to help me here?

saulosm avatar Jan 20 '20 20:01 saulosm

Please provide any valid form data. I am not from the same country as you and I cannot guess these values.

ad-m avatar Jan 23 '20 01:01 ad-m

I have same problem. On site that i trying break captcha, don´t have form , just have same

URL

ULR = https://www.nike.com.br/Snkrs/Produto/Air-Max-1-Premium/153-169-211-208971

ScrimForever avatar Feb 04 '20 23:02 ScrimForever

@ScrimForever , could you share on what operation on nike.com.br do you notice that issue? I was attempt to reproduce captcha, but i don't know when it's triggered.

ad-m avatar Jun 21 '20 09:06 ad-m

If you're still struggling, hmu on discord @ Paulie#2222

pmb2 avatar Jun 01 '21 01:06 pmb2

problem solved see #92

fashan7 avatar Aug 23 '21 01:08 fashan7