简体   繁体   中英

How to get text from a textarea we entered using selenium

How can I get the text that I entered in a text-area using Selenium where the text entered in the developer options in Chrome and Mozilla where in IE its visible in the developer section. Using gettext() I am able to get the text from IE but giving me nothing using the same for Chrome and Mozilla.

string text = 
       driver.findelement(
           by.xpath("//textarea[@placeholder='E‌​nter a description']")
       ).gettext();

尝试这个:

String text=driver.findelement(By.xpath("//textarea[@placeholder='E‌​nter a description']")).getAttribute("value");

One of the below attributes should get the text using following :

  • text
  • textContent
  • innerText
  • innerHTML
  • nodeValue
  • value

Providing vague solution since it is difficult to suggest without HTML

String text=driver.findelement(By.xpath("//textarea[@placeholder='E‌​nter a description']")).getAttribute("innerHTML")//or .getAttribute("outerHTML") ;

Use string functions to get the required value!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM