pythonseleniumselenium-webdriver

Get value of an input box using Selenium (Python)


I am trying to extract the text in an input box,

<input type="text" name="inputbox" value="name" class="box">

I started with

input = driver.find_element_by_name("inputbox")

I tried input.getText() but I got

AttributeError: 'WebElement' object has no attribute 'getText'

Solution

  • Use this to get the value of the input element:

    input.get_attribute('value')