Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

395
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!