1

I have HTML code as in below and I am trying to extract value using xpath.

<input id="searchCriteriaForm:memberNumber" name="searchCriteriaForm:memberNumber" type="text" value="143256789" maxlength="17" size="15" class="inputText">

My code is

print(driver.find_element_by_xpath('//*[@name="searchCriteriaForm:memberNumber"]').text)

code is not printing anything and no exception. I am expecting to print value "143256789'

let me know what's wrong with my code statement.

1
  • <input id="searchCriteriaForm:memberNumber" name="searchCriteriaForm:memberNumber" type="text" value="125690" maxlength="17" size="15" class="inputText"> Commented Mar 18, 2021 at 3:23

1 Answer 1

2

What you're looking for is not part of the text content - it is inside the value attribute of the tag.

You can use .get_attribute('value') instead of .text

.get_attribute() docs

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.