Selenium+Jave——获取web端元素文本
说明:attribute指web页面的定位方式,如id、xpath、name、class等;value指web页面的定位方式需要的参数
public void getTextOrValue(String attribute,string value) throws Exception{
driver=Hook.getDriver();
WebElement ele =driver.findElement(toFindBy(attribute,value));
if (ele != null){
System.out.println("Text():"+ ele.getText());
System.out.println("Value:"+ ele.getAttribute("Value"));
System.out.println("innerText():"+ ele.getAttribute("innerText"));
System.out.printIn("textContent():"+ ele.getAttribute("textContent"));
System.out.println("isEnable():"+ ele.isEnabled());
System.out.println("aria-disabled():"+ ele.getAttribute("aria-disabled"));
System.out.printIn("innerHTML():"+ ele.getAttribute("innerHTML"));
System.out.printIn("outerHTML():"+ ele.getAttribute("outerHTML"));
}
#测试##自动化测试#自动化测试学习 文章被收录于专栏
记录工作中的自动化测试学习内容,例如:手机自动化测试学习,web端自动化测试学习等..
