Saturday, 9 July 2016

Clickon each link

public class Linkclick {

WebDriver driver;
  @Test
  public void Click_on_link() {


//  webelement str=driver.findElement(arg0)
 //ul[@class='utility-nav pull-right']//a
 List<WebElement> allLinks = driver.findElements(By.xpath("//ul[@class='utility-nav pull-right']//a"));
 System.out.println("Total links -> "+ allLinks.size());
 for (int i = 0; i <= allLinks.size(); i++)
 {
 allLinks = driver.findElements(By.xpath("//ul[@class='utility-nav pull-right']//a"));
 System.out.println(allLinks.get(i).getText());
 allLinks.get(i).click();
 driver.navigate().back();
 }
  }
  @BeforeTest
  public void beforeTest() {
 System.setProperty("webdriver.chrome.driver", "F:\\chrome\\chromedriver.exe");
driver = new ChromeDriver();
 driver.get("https://www.oneamerica.com");
  }

  @AfterTest
  public void afterTest() {
  }

No comments:

Post a Comment