Friday, 8 May 2015

Selenium:How to handle Check list in selenium web driver

package New;

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.support.ui.Select;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;

public class CheckList {
    WebDriver driver;
  @Test
  public void checklist1() throws InterruptedException {
      driver.get("http://apsrtc.com/");
      driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
     // WebElement ele=driver.findElement(By.id("dropdownflag"));
      //driver.switchTo().frame("lang_selection");
      //driver.switchTo().frame(1);
      driver.switchTo().frame("apsrtc.com");
      Thread.sleep(6000);
     // driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
      WebElement ele=driver.findElement(By.xpath(".//select[@id='dropdownflag']"));
      Select s =new Select(ele);
      s.selectByIndex(5);
      //s.selectByValue("");
      //s.selectByVisibleText("");
      //s.deselectByIndex(0);
      //s.deselectByValue("");
      //s.deselectByVisibleText("");
      //s.deselectAll();
      Thread.sleep(6000);
     
  }
  @BeforeClass
  public void beforeClass() {
      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