0
votes

I'm going through a list to click on the Alquilar button found in Alquilar

<ul id="vertical-operation-menu">
  <li valorTipoHome="1" id="home-Venta" class="js-btn-home current vertical-operation-menu-btns">
    <a href="#">Comprar</a>
  </li>
  <li valorTipoHome="2" id="home-Alquiler" class="js-btn-home  vertical-operation-menu-btns">
    <a href="#">Alquilar</a>
  </li>
  <li valorTipoHome="desarrollosURL" id="home-Emprendimiento" class="js-btn-home  vertical-operation-menu-btns">
    <a href="#">Emprendimientos</a>
  </li>
  <li valorTipoHome="homeComercial_grupo_4" data-tipo-propiedad-dfp="4,5,10,8,45" id="home-Comercial" class="js-btn-home  vertical-operation-menu-btns">
    <a href="#">Comercial</a>
  </li>
  <li valorTipoHome="4" id="home-Vacacional" class="js-btn-home  vertical-operation-menu-btns">
    <a href="#">Temporal</a>
  </li>
</ul>

I am capturing it with XPATH in the following way

tipoOperacion = webdriver.find_element_by_xpath('//*[@id="home-Alquiler"]/a')
tipoOperacion.click()

but nothing happens

look at the data that I am capturing and return the name of the button

a = tipoOperacion.text
print(a)

ALQUILAR

But I can not click on the button

I add an answer to the question print(WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//a[text()='Alquilar']"))).text)

ALQUILAR

1
Did you try clicking the parent element instead of the link?Guy
@Guy I do not probe it, how would it be?Sebastian
tipoOperacion = webdriver.find_element_by_id('home-Alquiler')Guy
@Guy it did not workSebastian

1 Answers

0
votes

Try this see if it helps.

WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//a[text()='Alquilar']"))).click()

note: use following imports

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

EDIT:

from selenium.webdriver.common.action_chains import ActionChains
 element=driver.find_element_by_xpath("//a[text()='Alquilar']")
 ActionChains(driver).move_to_element(element).perform()

OR

driver.execute_script("arguments[0].click();",driver.find_element_by_xpath("//a[text()='Alquilar']"))