1

I want to fill up a textbox and then click on submit button using python. After clicking on the submit button, a opo up comes up with a captcha to be solved. I want to further read that captcha image to convert it into text and enter the security mechanism. Here is what I have already tried'

import selenium
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('www.abc.com')
id_box = browser.find_element_by_id('EnterNo')
id_box.send_keys('1234567890')

Upto this point the code is working. But, I am not able to click on the submit button after this, i.e. the below code is not working

submit_button = browser.find_element_by_name('SubmitButton')
submit_button.click()

This throws the following error :

ElementNotInteractableException: Message: Element <input id="SubmitButton" name="SubmitButton" type="hidden"> could not be scrolled into view
Anand Nautiyal
  • 245
  • 2
  • 5
  • 11
  • @DebanjanB - This is not a duplicate. I want to fetch the captcha after clicking on the submit button and solve it. This is a totally different question. Why have you marked it duplicate?? – Anand Nautiyal Oct 08 '18 at 09:44
  • Reopened the discussion !!! – undetected Selenium Oct 08 '18 at 09:45
  • Are you sure you are able to click on this element? `type='hidden'` doesn't have any rendering on the screen. Try sending ENTER to the `id_box` to trigger a submit. You can also call `id_box.submit()` which should also trigger a form submit. – Dakshinamurthy Karra Oct 08 '18 at 10:38

1 Answers1

2

seems the button cannot be clicked due its out of view-side. You need to scroll and then click.

Here is an example JS code for scroll to web element and click it.

element = driver.find_element_by_id("element id");
driver.execute_script("arguments[0].scrollIntoView(true); arguments[0].click();", element);

Update

Actions can also do the job:

actions = ActionChains(driver)
element = driver.find_element_by_id("element id")
actions.move_to_element(element).click(element).perform()
Infern0
  • 2,565
  • 1
  • 8
  • 21