
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get value of an input box using Selenium (Python)
We can get the value of an input box with Selenium webdriver. The get_attribute() method is capable of obtaining the value we have entered in an input box. To get the value, we have to pass value as a parameter to the method.
First of all, we have to identify the input box with the help of any of the locators like id, class, name, css or xpath. Then we have to type some values inside it with the send_keys() method.
Let us consider the below input box where we shall enter some texts - Selenium Python and then fetch the value with get_attribute().
Example
from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.google.com/") #identify element l= driver.find_element_by_name("q") l.send_keys("q") #get_attribute() to get value of input box print("Value of input box: " + l.get_attribute('value')) driver.close()
Output
- Related Questions & Answers
- How to retrieve value from an edit box using Selenium webdriver?
- How to get the value of the edit box in Selenium?
- How to input letters in capital letters in an edit box in Selenium with python?
- Using Selenium Web Driver to retrieve value of a HTML input.
- How to get an attribute value of an element in Selenium Webdriver?
- How to input text in the text box without calling the sendKeys() using Selenium?
- Get HTML Source of WebElement in Selenium WebDriver using Python.
- How to enter values in an edit box in Selenium with python?
- How to set “value” to input web element using selenium?
- How to get the attribute value of a web element in Selenium (using Java or Python)?
- How to disable/enable an input box with jQuery?
- How to get the input value of the first matched element using jQuery?
- How to key in values in input text box with Javascript executor in Selenium with python?
- Get text using selenium web driver in python?
- How to press ENTER inside an edit box in Selenium?
Advertisements