簡體   English   中英

如何從 Selenium 中的標簽中獲取值

[英]How to get the value from a tag in Selenium

我們如何在 selenium 中獲取 value 部分中的值

我需要使用 selenium 在 value 下存在的字符串中檢索 Mr。

由於它不是自由文本,所以 getText() 不起作用。

根據您的要求,您可以試試這個

這是您的 HTML 代碼:

 <input class="title" type="text" value="Mr">

硒代碼:

 String textvalue=driver.findElement(By.xpath("//input[@value='Mr']")).getAttribute("value");

 System.out.println(textvalue);

對於蟒蛇:

value=driver.find_element_by_id('tag ID')
print(value.text)

爪哇:

System.out.println(driver.findElement(By.id('tag ID')).getText());

暫無
暫無

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

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