0

I have googled this extensively but can't get to an answer, I'm trying to extract "90,856" in the title. It's value changes over time:

<div class="card hreddeep">
<div class="card-header hbuilt">
<div class="card-body">
<div class="row">
<div class="col-6 text-left">
<div class="h6 text-uppercase param-title">Search<br>Volume</div>
<div class="h4 param-content" title="90,856">

my code is:

find_element_by_xpath("//div[@class='h4-param-content']").get_attribute("title")

grateful for some help. Thanks

1 Answer 1

1

Your XPath contains a typo (according to your sample data) : h4-param instead of h4 param...

First, test with :

find_element_by_xpath("//div[@class='h4 param-content']").get_attribute("title")

If it doesn't work, try with an expected condition.

Add the following imports :

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

Code :

wait = WebDriverWait(driver, 10)
output = wait.until(EC.visibility_of_element_located((By.XPATH, "//div[@class='h4 param-content']"))).get_attribute("title")
print(output)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.