1

How to extract xpath of this (title=" I want to get this item")

<div class="ads__item__actions">
<a href="https://www.xxx.html" title="I want to get this item" class="ads__item__ad--title" 
xpath="1">
some text</a>
</div>
5
  • Depends on the language you are using. This question here has an answer for users of Python >>> stackoverflow.com/questions/51590374/… Commented Jun 16, 2020 at 20:25
  • Where's the closing tag for the first div? Commented Jun 16, 2020 at 21:37
  • the closing tag is </div> @jackFleeting Commented Jun 16, 2020 at 21:51
  • I understand, but where is it located - before the <a> tag or after? Commented Jun 16, 2020 at 22:14
  • after <a> tag it at the end of the above code Commented Jun 16, 2020 at 22:21

1 Answer 1

0

Assuming you have the (corrected) html snippet in your question, then

 titles = driver.find_elements_by_xpath('.//div/a')
 print(titles[0].get_attribute('title'))

should output:

I want to get this item
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.