## 選擇器
### By ID
頁面:
```
<input type="text" name="passwd" id="passwd-id" />
```
代碼:
```
WebElement element = driver.findElement(By.id("passwd-id"));
```
### By Name
頁面同上
代碼:
```
WebElement e = dr.findElement(By.name("passport_51_user"));
```
### By XPATH
```
WebElement element
= driver.findElement(By.xpath("//input[@id='passwd-id']"));
```
### By Class Name
頁面:
```
<div class="cheese">
<span>Cheddar</span>
</div>
<divclass="cheese">
<span>Gouda</span>
</div>
```
代碼:
```
List<WebElement> cheeses
= driver.findElements(By.className("cheese"));
```
### By Link Text
頁面:
```
<a href="http://www.google.com/search?q=cheese">cheese</a>
```
代碼:
```
WebElement cheese = driver.findElement(By.linkText("cheese"));
```