Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
Python selenium find element by xpath or css selector

how can i click on the "NATIONAL" text with python selenium

<div class="ellipsis__content">
    <ul class="breadcrumb_new" id="breadcrumb">
       <li>
         <span>NATIONAL</span>
       </li>
    </ul>
</div>

I tried these below things,

find_element_by_xpath("//div[@id='breadcrumb']/li/span")
find_element_by_css_selector("#breadcrumb > li > span")

Both the methods not working, any idea here

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Try this one, should work for you:

ele=driver.find_element_by_xpath("//*[@id='breadcrumb']//span")
ele.click()
about 4 years ago · Juan Pablo Isaza Denunciar

0

Already this question has an answered but adding couple of points.

I tried these below things,

find_element_by_xpath("//div[@id='breadcrumb']/li/span")

The id breadcrumb is part of ul tag but you are referring div tag. It should work if try as below.

find_element_by_xpath("//ul[@id='breadcrumb']/li/span")

find_element_by_css_selector("#breadcrumb > li > span")

There is nothing wrong with CSS locator. It should work still if you are seeing issue you may need to debug and see or try by adding some explicit value.

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar

0

May be you need to wait till element is rendered properly.

Code trial 1 :

time.sleep(5)
driver.find_element_by_xpath("//div[@id='breadcrumb']/li/span").click()

Code trial 2 :

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='breadcrumb']/li/span"))).click()

PS : Please check in the dev tools (Google chrome) if we have unique entry in HTML DOM or not.

Steps to check:

Press F12 in Chrome -> go to element section -> do a CTRL + F -> then paste the xpath and see, if your desired element is getting highlighted with 1/1 matching node.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda