簡體   English   中英

通過元素xpath獲取值

[英]get value by element xpath

<input id="ctl00_MainContent_AllowanceGridView_ctl46_DHD" 
class="allowanceValue" type="text" 
onkeydown="return formattime(this,event);" value="00:56" name="ctl00$MainContent$AllowanceGridView$ctl46$DHD"/>

Java如何通過seleniun獲得value = 00:56? 嘗試使用.getText(); ,但是沒有得到我的價值嗎?

通過id查找元素,然后使用getAttribute()獲取value屬性:

WebElement element = driver.findElement(By.id("ctl00_MainContent_AllowanceGridView_ctl46_DHD"));
System.out.println(element.getAttribute("value"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM