javascript
  • angularjs
  • selenium
  • selenium-webdriver
  • 2016-12-29 56 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") ; 
    

    使用字符串函數建議得到所需的值!

    相關問題