一、获取页面的表格有多少行
List rows =driver.findElements(By.xpath("//[@id='UpdatePanel1']/div[2]/table/tbody/tr"));
System.out.println(rows.size());
二、下拉选择输入框的定位方法
1、driver.findElement(By.xpath(getElement.HAND_INPUT_XPATH)).click();
2、WebElement from_inpox =driver.findElement(By.xpath(getElement.HAND_FORMINPUT_XPATH));
Actions actions =newActions(driver);
actions.moveToElement(from_inpox).click().perform();
3、driver.findElement(By.xpath(getElement.HAND_INPUTTEXT_XPATH)).click();
三、判断一个元素是否存在
public booleanisElementPresent(WebDriver driver,By el) {
try{
System.out.println("存在");
driver.findElement(el);
return true;
}
catch(Exception e) {
System.out.println("不存在");
return false;
}
}