Unable To Locate Element Selenium Webdriver
I'm trying to scrape the following website: https://www.bancosantander.es/es/particulares/prestamos/prestamo-coche/simulador What I'm trying to do: Simulate the amount and duration
Solution 1:
You can try the following for entering your values
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
url = 'https://simuladores.bancosantander.es/SantanderES/loansimulatorweb.aspx?por=webpublica&prv=publico&m=100&cta=1&ls=0#/t0'
driver = webdriver.Chrome()
driver.get(url)
amount = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#amount")))
amount.clear()
amount.send_keys(6000)
WebDriverWait(driver, 30).until(lambda driver: driver.execute_script('return jQuery.active') == 0)
term = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#term")))
term.clear()
term.send_keys('60 meses')
term.send_keys(Keys.TAB)
currentCuota = driver.find_element_by_css_selector('.r1 span').text
WebDriverWait(driver, 10).until(lambda driver: driver.execute_script('return jQuery.active') == 0)
while driver.find_element_by_css_selector('.r1 span').text == currentCuota:
continue
print('Tu cuota mensual: ' + driver.find_element_by_css_selector('.r1 span').text)
Solution 2:
Your xpath is not working due to the space in the class name. Not sure if that's the only issue but is a problem. The following line should find your element if that class name is correct.
webdriver.find_element_by_css_selector('div.res.r1')
Post a Comment for "Unable To Locate Element Selenium Webdriver"