package detective.webdriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; /** * All Action puts here * @author James Luo * */ public class ActionBot { private final WebDriver driver; public ActionBot(WebDriver driver) { this.driver = driver; } public void click(By locator) { driver.findElement(locator).click(); } public void submit(By locator) { driver.findElement(locator).submit(); } /** * Type something into an input field. WebDriver doesn't normally clear these * before typing, so this method does that first. It also sends a return key * to move the focus out of the element. */ public void type(By locator, String text) { WebElement element = driver.findElement(locator); element.clear(); element.sendKeys(text + "\n"); } }