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

396
Vistas
How to get value using python selenium of element that is not selectable

I am trying to get a value 570 using Python selenium.

...
<div _ngcontent-lci-c225="" class="mr-4 bd-highlight">
    <span _ngcontent-lci-c225="" class="clickable ng-star-inserted" style="margin-right: 5px;">Bank</span>
    <!---->
    570
    </div>

I am not sure what is and why when I highlight it in chrome dev tools it doesn't show me anything in styles window where I would usually see something. Tried googling to get the meaning of without success. If anyone knows please explain to me.

My code:

driver.find_element(By.XPATH, "/html/body/app-root/ng-component/div[4]/mat-drawer-container/mat-drawer-content/mat-grid-list/div/mat-grid-tile[2]/figure/app-inventory-menu/div/div[1]/div[2]/div[2]/span").get_attribute('innerHTML')

It returns 'Bank' and not the actual numerical value that I need. Not sure what else I can do?

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

0

Thank you for suggestion I was able to figure it out.

driver.find_element(By.CSS_SELECTOR, "div.inventory-row:nth-child(1) > div:nth-child(2) > div:nth-child(2)").text.strip("Bank")

Maybe there is a better way, but it works for me.

about 4 years ago · Juan Pablo Isaza Denunciar

0

It's because the number is not contained within the <span> element, but rather the <div> element above it. Based on your code, the best selector I can find for it is the CSS Selector: "div.mr-4.bd-highlight"

about 4 years ago · Juan Pablo Isaza Denunciar

0

parent = driver.find_element(By.CSS_ELECTOR,"mr-4.bd-highlight")
child = parent.find_element(By.TAG_NAME,"span")
print (parent.text.replace(child.text, ''))

Try to remove the span text. I know there's a way better way then this using split.

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