package demo; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; public class HomePage { public String base_url = "https://www.baidu.com/"; public WebDriver driver; WebElement inputBox; WebElement searchButton; /** * @author Young * @param message */ public void typeInputBox(String message) { inputBox = driver.findElement(By.id("kw")); inputBox.clear(); inputBox.sendKeys(message); } /** * @author Young */ public void clickSearchButton() { searchButton = driver.findElement((By.cssSelector("input#su"))); searchButton.click(); driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS); } /** * @author Young * @param d */ HomePage(WebDriver d) { this.driver = d; driver.get(base_url); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS); } /** * @author Young * @return */ public String getTitle() { return driver.getTitle(); } }
时间: 2024-11-05 21:39:40