0

I'm trying to access a textbox to enter some values in it, but my code doesn't find the element I'm searching for (I've tried it via xpath, id, and class).

Since I have a WebDriverWait condition, a TimeoutException occurs. I really don't understand what I'm doing wrong, since this method worked for other pages I tried it in!

My code (and webpage):

driver = webdriver.Chrome()
driver.get('https://www.bancosantander.es/es/particulares/prestamos/prestamos-personales/simulador')

# Find textbox
amountBox = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="amount"]')))

# Set amount to 10000  
amountBox.clear()
amountBox.send_keys('10000')

Error message:

Traceback (most recent call last):

File "C:\Users\Python\.spyder-py3\scrapingTest.py", line 14, in <module>
amountBox = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="amount"]')))

File "C:\Users\Python\anaconda3\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)

TimeoutException

Any help will be appreciated!

2 Answers 2

1

An iframe is present on the page, so you need to first switch to that iframe and then operate on the element.
You can do it like:

driver = webdriver.Chrome()
driver.get('https://www.bancosantander.es/es/particulares/prestamos/prestamos-personales/simulador')

#Switch to the iframe
driver.switch_to.frame(driver.find_element_by_tag_name('iframe'))

# Find textbox
amountBox = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="amount"]')))

# Set amount to 10000  
amountBox.clear()
amountBox.send_keys('10000')
Sign up to request clarification or add additional context in comments.

Comments

0

It's inside iframe, you need switch it first.

Please utilize .frame_to_be_available_and_switch_to_it method:

driver.get('https://www.bancosantander.es/es/particulares/prestamos/prestamos-personales/simulador')

WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, 'iframe[src]')))

# Find textbox
amountBox = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="amount"]')))

# Set amount to 10000  
amountBox.clear()
amountBox.send_keys('10000')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.