WebDriver??????????е????????
???????????? ???????[ 2015/2/13 16:20:06 ] ?????????????????? WEbDriver
???????????
????1. ???????????е?tr???浽list????
????2.??tr?????????????????tr????????????td?????浽list????
????3.?????????td??????
????????????
package com.example.tests;
import static org.junit.Assert.*;
import java.util.*;
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Selenium2 {
WebDriver driver = new InternetExplorerDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
@Test
public void tableTest() {
driver.get("http://www.w3school.com.cn/html/html_tables.asp");
//??????????tr?????
List<WebElement> rows = driver.findElements(By.cssSelector(".dataintable tr"));
//???????????
assertEquals(11??rows.size());
//????????????????????
for (WebElement row : rows) {
//??????tr??td?????
List<WebElement> cols = row.findElements(By.tagName("td"));
for (WebElement col : cols) {
System.out.print(col.getText());//???td??????
}
System.out.println();
}
driver.close();
}
}
???????????
????---------------------------------------------------------------------------------
????<table>??????
????<caption>?????????
????<th>???????????
????<tr>????????С?
????<td>?????????
????<thead>????????ü??
????<tbody>??????????塣
????<tfoot>???????????
????<col>???????????е??????
????<colgroup>???????е??顣
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11