I'm facing the following issue with Selenium:
I've successfully completed the fields "Origen" and "Destino", however, the values after the script occurs, disappear.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
#Opciones navegacion
options = webdriver.ChromeOptions()
options.add_argument('--start-maximized')
options.add_argument('--disable-extensions')
driver_path = "C:/Users/Diego/Downloads/chromedriver.exe"
driver = webdriver.Chrome(driver_path, chrome_options = options)
#Iniciar en la pantalla 2
#driver.set_window_position(2000,0)
driver.maximize_window()
time.sleep(1)
#Inicializamos el navegador
driver.get('https://www.starken.cl/cotizador')
WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"input#rc_select_6"))).send_keys('SANTIAGO')
WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"input#rc_select_7"))).send_keys('VINA DEL MAR')
I'll be thankful for any suggestion.
CodePudding user response:
Sometimes with dropdowns, a user input is required to confirm the selection can be mouse click or the enter button. I went for the latter. I also added some time to your wait function as it took longer for the page to load where I am, and the wait expired. This is only a "wait for up to" not a "wait for."
It's also worth mentioning if your input results in multiple items, you may need to make a further selection; i.e. which item from those results?
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
#Opciones navegacion
options = webdriver.ChromeOptions()
options.add_argument('--start-maximized')
options.add_argument('--disable-extensions')
#driver_path = "C:/Users/Diego/Downloads/chromedriver.exe"
driver = webdriver.Chrome()
#Iniciar en la pantalla 2
#driver.set_window_position(2000,0)
driver.maximize_window()
time.sleep(1)
#Inicializamos el navegador
driver.get('https://www.starken.cl/cotizador')
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"input#rc_select_6"))).send_keys('SANTIAGO' u'\ue007' )
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"input#rc_select_7"))).send_keys('VINA DEL MAR' u'\ue007')
CodePudding user response:
These <input>
s are ant based input boxes with a role of combobox which generates