Friday, 8 May 2015

Selenium:How to identify the frames in selenium web driver

package frameexamples;

import java.util.Iterator;
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.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class FrameIdentification {

    WebDriver driver;
      @Test
      public void dragdrop() throws InterruptedException {
          driver.get("http://jqueryui.com/");
          driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
         /*List<WebElement> l= driver.findElements(By.tagName("iframe"));
         for (WebElement webElement : l) {
            System.out.println(webElement.getText());
        }*/
          List<WebElement> l= driver.findElements(By.tagName("iframe"));
          Iterator itr=l.iterator();
          while (itr.hasNext()) {
            WebElement ele=(WebElement) itr.next();
            System.out.println(ele.getText());
           
        }
          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