Selenimu2Example

package demo;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.reporters.EmailableReporter;


public class Selenimu2Example {
public static void main(String[] args) {
System.setProperty("webdriver.firefox.bin","D:\\firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
// driver.navigate().to("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Selenium");
element.submit();
System.out.println("Page title is " + driver.getTitle());
new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("Selenium");
}
});


System.out.println("page title is :" + driver.getTitle());
driver.quit();
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章