Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:46:14+00:00 2026-06-02T08:46:14+00:00

I must be thinking about this wrong. I want to get the contents of

  • 0

I must be thinking about this wrong.

I want to get the contents of an element, in this case a formfield, on a page that I am accessing with Webdriver/Selenium 2

Here is my broken code:

 Element=driver.find_element_by_id(ElementID)
 print Element
 print Element.text

here is the result:

<selenium.webdriver.remote.webelement.WebElement object at 0x9c2392c>

(Notice the blank line)
I know that element has contents since I just stuffed them in there with the previous command using .sendkeys and I can see them on the actual web page while the script runs.

but I need to get the contents back into data.

What can I do to read this? Preferably in a generic fashion so that I can pull contents from varied types of elements.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:46:15+00:00Added an answer on June 2, 2026 at 8:46 am

    I believe prestomanifesto was on the right track. It depends on what kind of element it is. You would need to use element.get_attribute('value') for input elements and element.text to return the text node of an element.

    You could check the WebElement object with element.tag_name to find out what kind of element it is and return the appropriate value.

    This should help you figure out:

    driver = webdriver.Firefox()
    driver.get('http://www.w3c.org')
    element = driver.find_element_by_name('q')
    element.send_keys('hi mom')
    
    element_text = element.text
    element_attribute_value = element.get_attribute('value')
    
    print element
    print 'element.text: {0}'.format(element_text)
    print 'element.get_attribute(\'value\'): {0}'.format(element_attribute_value)
    driver.quit()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that somewhere in the history of the internet this must have been
Let me describe the situation, and I'm sure I'm just thinking about this problem
Some background: I came across something the other day that got me thinking about
Am I thinking about this incorrectly?? Or missing something completely obvious? I can best
I'm thinking about an application which recieves massive Data from the User. But this
I need your help, cause I'm thinking about how to resolve this problem and
I was thinking about this during my morning shower, how can I construct HTML
Must be a way looping through this code: private void loadSprites() { this.sprites[0] =
Must Support IE6 and must Validate vs XHTML Strict 1.0! This is tricky to
There must be a simple solution to this problem but for the love of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.