0

I'm learning xpath and Selenium, and just successfully found the element I am trying to target. I am searching for a element where data-number = 48264

driver.find_element_by_xpath("//*[@data-number='48264']")

The HTML I am pulling from looks like this

<li id="pos_4" data-number="48264" class="top-item sellmid">

Now I am trying to return the ID "pos_4". I experimented with the below code, but it was totally wrong.

driver.find_element_by_xpath("//*[@data-asin='B01923Y7IG']").id

This returned a long float "0.066103113793198-1". Not sure what this is.

driver.find_element_by_xpath("//*[@data-asin='B01923Y7IG']").text

The above returned the text inside the div of the li.

Any suggestions on where to look next? I've done a lot of searching, but couldn't find anything helpful. Thanks!

1 Answer 1

1

you can do that by

ele = driver.find_element_by_xpath("//*[@data-number='48264']")

value = ele.get_attribute('id')

print value
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.