如何通过Java使用Selenium从元素中提取文本

问题描述 投票:-2回答:1

如何获取此元素的文本:

<div class="status-value" id="divdoctyp" xpath="1">AADHAAR CARD</div>

我尝试过此

WebElement doctype= driver.findElement(By.xpath("//div[@id='divdoctyp']"));
String type=doctype.getAttribute("type"); 
String label=doctype.getText();
Thread.sleep(5000);
System.out.print("doctype is "+type +"\n"+label);
java selenium-webdriver gettext webdriverwait getattribute
1个回答
0
投票

要从元素中提取文本AADHAAR CARD

© www.soinside.com 2019 - 2024. All rights reserved.