1

I have HTML as shown (modified to make it brief)

ht=<a class="title" href="http:/www.myref.com/1235" title="This is link to my ref">This is my ref</a>

Now from here, I want to extract the "http:/www.myref.com/1235"

ht.get_text()

gives me only the text part This is my ref.

3
  • ht.getAttribute('href') geeksforgeeks.org/get_attribute-element-method-selenium-python Commented Apr 17, 2022 at 4:35
  • @TimRoberts thanks, I get TypeError: 'NoneType' object is not callable in my try. Commented Apr 17, 2022 at 4:45
  • Please add more detail like code snippet and error stacktrace Commented Apr 17, 2022 at 5:03

1 Answer 1

1

If ht is a webelement then,

ht.get_attribute('href')

should give you http:/www.myref.com/1235

Since you are getting TypeError: 'NoneType' object is not callable

This could mean either

  1. ht is not a web element.

  2. ht is not rendered properly.

Put some delay before ht and try again with ht.get_attribute('href')

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.