How can I get text from text box, search box from webpage. I am trying to get text and and get length to check if it's empty. eg
driver = webdriver.Chrome()
driver.get('http://www.yahoo.com')
I tried driver.find_element_by_name('p').text
But it prints out null even though text is there.
For input
web element use el.get_attribute('value')
:
In [14]: driver = webdriver.Chrome()
In [15]: driver.get('http://www.yahoo.com')
In [16]: search = driver.find_element_by_css_selector('input[title=Search]')
In [17]: search.get_attribute('value')
Out[17]: u''
In [18]: search.send_keys('SO the best!')
In [19]: search.get_attribute('value')
Out[19]: u'SO the best!'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.