Thursday 19 June 2014

selenium program for display all the textbox id and dropdown id

 selenium program for display all the textbox id and dropdown id


solution:----
import java.util.List;

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

public class listsofelement {
public WebDriver driver;
public void verify_textbox() {
 driver.findElement(By.className("registernow")).click();
 List<WebElement> str=driver.findElements(By.className("textbox_1"));
 System.out.println(str.size());
 for (int i = 0; i <str.size(); i++) {
 System.out.println(str.get(i).getAttribute("id"));
}
 }
 @Test 
 public void verify_dropdown()
 {
 driver.findElement(By.className("registernow")).click();

 
 List<WebElement> str2= driver.findElements(By.tagName("select"));
 System.out.println(str2.size());
 for (int i = 0; i < str2.size(); i++) {
 System.out.println(str2.get(i).getAttribute("id"));
}
 }
 @BeforeTest
 public void beforeTest() {
driver=new FirefoxDriver();
driver.get("http://mail.in.com");
 }

  @AfterTest
  public void afterTest() {
  }

}


No comments:

Post a Comment