Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium not submitting form with anticaptcha #47

Open
priteshthaker1501 opened this issue Nov 19, 2019 · 8 comments
Open

Selenium not submitting form with anticaptcha #47

priteshthaker1501 opened this issue Nov 19, 2019 · 8 comments

Comments

@priteshthaker1501
Copy link

priteshthaker1501 commented Nov 19, 2019

@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 priteshthaker1501 changed the title Selenium not submitting form Selenium not submitting form with anticaptcha Nov 19, 2019
@ad-m
Copy link
Owner

ad-m commented Nov 28, 2019

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
Copy link
Owner

ad-m commented Jan 11, 2020

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

@saulosm
Copy link

saulosm commented Jan 20, 2020

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 <textarea id="g-recaptcha-response-1" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea>.

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

Do you have any clue to help me here?

@ad-m
Copy link
Owner

ad-m commented Jan 23, 2020

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

@ScrimForever
Copy link

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

<textarea id="g-recaptcha-response-1" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea>

URL

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

@ad-m
Copy link
Owner

ad-m commented Jun 21, 2020

@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.

@pmb2
Copy link

pmb2 commented Jun 1, 2021

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

@fashan7
Copy link

fashan7 commented Aug 23, 2021

problem solved
see #92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants