Saturday 21 June 2014

All submenu from the menu list

package Webdriverprgs;

import java.awt.List;

import javax.swing.text.TabableView;

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.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

import com.google.common.collect.Table;

public class submenu  {
    public WebDriver driver;
  @Test
  public void f() {
      Actions act=new Actions(driver);
      WebElement str=driver.findElement(By.linkText("Series"));
      act.moveToElement(str).build().perform();
      WebElement submenu=driver.findElement(By.id("mgDdRht"));
      java.util.List<WebElement> allrows1=submenu.findElements(By.tagName("tr"));
     for(WebElement row:allrows1){
            java.util.List<WebElement> allcols = row.findElements(By.tagName("td"));
      for (WebElement col : allcols){
      System.out.println(col.getText());
      }     
      }
     
  }
  @BeforeTest
  public void beforeTest() {
      driver=new FirefoxDriver();
      driver.get("http://www.espncricinfo.com/");
      driver.manage().window().maximize();
     
  }

  @AfterTest
  public void afterTest() {
  }

}

No comments:

Post a Comment