javascript
  • angularjs
  • selenium
  • selenium-webdriver
  • 2016-12-29 59 views 1 likes 
    1

    如何在使用Selenium的文本区域中输入文本,其中在Chrome和Mozilla的开发人员选项中输入的文本在开发人员可见的IE中部分。使用gettext()我可以从IE获得文本,但是没有给Chrome和Mozilla使用相同的内容。如何从我们使用硒输入的textarea中获取文本

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

    向我们展示您的代码:) – MeanGreen

    +0

    string text = driver.findelement(by.xoath(“// textarea [@ placeholder ='Enter a description']”))。gettext(); –

    +0

    你累了。请显示你的代码 –

    回答

    0

    试试这个:

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

    也尝试过,没有用。其实它没有属性'价值'。 –

    +0

    @ManiKanta,你是否得到这个代码的异常,或者你得到空字符串? – Andersson

    +0

    发布HTML代码。 –

    0

    其中下面的属性应该得到的文本使用下列内容:

    • 文本
    • 的textContent
    • 的innerText
    • 的innerHTML
    • 的nodeValue
    0

    提供了模糊的解决方案,因为它是很难在不HTML

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

    使用字符串函数建议得到所需的值!

    相关问题