Selenium WebDriver get text from input field
This is the input
element - you need to get the value
attribute:
webDriver.findElement(By.id("inputTag")).getAttribute("value")
Get value of an input box using Selenium (Python)
Use this to get the value of the input element:
input.get_attribute('value')
Get current value of a webelement in selenium after clicking a button
It seems that although '20' is entered into the field, the "value" attribute still remains '0'.
Try this:
elem = driver.find_element_by_xpath("[YOUR_PATH_HERE]")
elem.get_attribute("innerHTML")
print(elem)
You could double click the field and copy the value.
from selenium.webdriver.common.action_chains import ActionChains
import pyperclip
elem = driver.find_element_by_xpath("[YOUR_PATH_HERE]")
actions = ActionChains(driver)
actions.double_click(elem).perform()
elem.send_keys(u'\ue009', 'c') # This is CONTROL + C
text = pyperclip.paste()
Selenium (Java): Retrieve value from disabled input text field
You can try via JavascriptExecutor
:
Thread.sleep(3) // add a pause to wait until value of the element will be rendered
JavascriptExecutor je = (JavascriptExecutor) driver;
String script = "return document.getElementById('NameInputID').getAttribute('value');");
String value = je.executeScript(script);
Related Topics
Subclassing a Java Builder Class
Double Checked Locking in Singleton
How to Run Testng from Command Line
Difference Between Jar and War in Java
Converting Roman Numerals to Decimal
Java Gui Frameworks. What to Choose? Swing, Swt, Awt, Swingx, Jgoodies, Javafx, Apache Pivot
What Is Recommended Way for Spawning Threads from a Servlet in Tomcat
Method Chaining + Inheritance Don't Play Well Together
How to Do Arithmetic Operations on the Number Baseclass
How to Bring a Window to the Front
Executing Another Application from Java
Clone() VS Copy Constructor VS Factory Method
Using Selenium Webdriver to Retrieve the Value of an HTML Input