package frameexamples;
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.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AutoComplete {
WebDriver driver;
@Test
public void frameOperation() throws InterruptedException {
driver.navigate().to("http://jqueryui.com/");
driver.findElement(By.linkText("Autocomplete")).click();
List<WebElement> l=driver.findElements(By.tagName("iframe"));
for (WebElement webElement : l) {
System.out.println(webElement.getText());
}
driver.switchTo().frame(0);
driver.findElement(By.xpath(".//*[@id='tags']")).sendKeys("java");
Thread.sleep(5000);
//switch back to default content
driver.switchTo().defaultContent();
driver.findElement(By.xpath(".//*[text()='Accordion']")).click();
/* //index
// driver.switchTo().frame(0);
//id or Name
//in this example Frame is not having ID or Name so this is invalid here
//driver.switchTo().frame("nameorid");
//frameElement
driver.switchTo().frame(driver.findElement(By.className("demo-frame")));
//type in text box..
driver.findElement(By.id("tags")).sendKeys("java");
Thread.sleep(5000);
//switch back to default content
driver.switchTo().defaultContent();
driver.findElement(By.linkText("Accordion")).click();*/
Thread.sleep(5000);
}
@BeforeClass
public void beforeClass() {
System.setProperty("webdriver.firefox.bin",
"C:\\Users\\RAMESH\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
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.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AutoComplete {
WebDriver driver;
@Test
public void frameOperation() throws InterruptedException {
driver.navigate().to("http://jqueryui.com/");
driver.findElement(By.linkText("Autocomplete")).click();
List<WebElement> l=driver.findElements(By.tagName("iframe"));
for (WebElement webElement : l) {
System.out.println(webElement.getText());
}
driver.switchTo().frame(0);
driver.findElement(By.xpath(".//*[@id='tags']")).sendKeys("java");
Thread.sleep(5000);
//switch back to default content
driver.switchTo().defaultContent();
driver.findElement(By.xpath(".//*[text()='Accordion']")).click();
/* //index
// driver.switchTo().frame(0);
//id or Name
//in this example Frame is not having ID or Name so this is invalid here
//driver.switchTo().frame("nameorid");
//frameElement
driver.switchTo().frame(driver.findElement(By.className("demo-frame")));
//type in text box..
driver.findElement(By.id("tags")).sendKeys("java");
Thread.sleep(5000);
//switch back to default content
driver.switchTo().defaultContent();
driver.findElement(By.linkText("Accordion")).click();*/
Thread.sleep(5000);
}
@BeforeClass
public void beforeClass() {
System.setProperty("webdriver.firefox.bin",
"C:\\Users\\RAMESH\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
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