package New;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class Autosuggestions {
WebDriver driver;
@Test
public void autosuggests() {
driver.get("http://www.bing.com/");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("sb_form_q")).sendKeys("webdriver");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
/*
* List<WebElement>
* sug=driver.findElements(By.xpath("//ul[@id='sa_ul']/li"));
* driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
* System.out.println(sug.size()); for (int i = 0; i < sug.size(); i++)
* { System.out.println(sug.get(i).getText());
*
* }
*/
driver.findElement(By.xpath("//ul[@id='sa_ul']/li[3]")).click();
;
}
@BeforeClass
public void beforeClass() {
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class Autosuggestions {
WebDriver driver;
@Test
public void autosuggests() {
driver.get("http://www.bing.com/");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("sb_form_q")).sendKeys("webdriver");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
/*
* List<WebElement>
* sug=driver.findElements(By.xpath("//ul[@id='sa_ul']/li"));
* driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
* System.out.println(sug.size()); for (int i = 0; i < sug.size(); i++)
* { System.out.println(sug.get(i).getText());
*
* }
*/
driver.findElement(By.xpath("//ul[@id='sa_ul']/li[3]")).click();
;
}
@BeforeClass
public void beforeClass() {
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}
No comments:
Post a Comment