表格脚本(打印行与列)

String url = "file:///D:/tomcat/apache-tomcat-7.0.26/webapps/08web/WebContent/table.html";
		driver.get(url);
		String title = driver.getTitle();
		String currentUrl = driver.getCurrentUrl();
		System.out.println(title);
		System.out.println(currentUrl);
		WebElement table = driver.findElement(By.tagName("table"));
		List trs = table.findElements(By.tagName("tr"));		
		 for (WebElement tr : trs) {
			List tds = tr.findElements(By.tagName("td"));
			for (WebElement td : tds) {
				String text = td.getText();
				System.out.println(text);
				
			}
		}

你可能感兴趣的:(表格脚本(打印行与列))