document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package test;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.firefox.FirefoxDriver;
  7. import org.openqa.selenium.support.ui.ExpectedConditions;
  8. import org.openqa.selenium.support.ui.Select;
  9. import org.openqa.selenium.support.ui.WebDriverWait;
  10. import org.testng.annotations.AfterTest;
  11. import org.testng.annotations.BeforeTest;
  12. import org.testng.annotations.Test;
  13.  
  14. public class CascadingDropDown_visibility  {
  15.     public WebDriver driver;
  16.     public WebDriverWait wait;
  17.  
  18.     @Test
  19.     public void cddTest() throws Throwable {
  20.         //Explicit wait
  21.         wait = new WebDriverWait(driver, 10);
  22.         //Drop down 1
  23.         WebElement dd1= driver.findElement(By.id("ctl00_SampleContent_DropDownList1"));
  24.         //Drop down 2
  25.         WebElement dd2= driver.findElement(By.id("ctl00_SampleContent_DropDownList2"));
  26.         //Drop down 3
  27.         WebElement dd3= driver.findElement(By.id("ctl00_SampleContent_DropDownList3"));
  28.         //Select a value from Dropdown 1
  29.         Select s1 = new Select(dd1);
  30.         s1.selectByVisibleText("Audi");
  31.         //Wait until a option loads in second dropdown
  32.         wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//select[@id=\'ctl00_SampleContent_DropDownList2\']/option[2]")));
  33.         Select s2 = new Select(dd2);
  34.         s2.selectByVisibleText("A6");
  35.         //Wait until a option loads in Third dropdown
  36.         wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//select[@id=\'ctl00_SampleContent_DropDownList3\']/option[2]")));
  37.         Select s3 = new Select(dd3);
  38.         s3.selectByVisibleText("Cyan");
  39.         Thread.sleep(5000);
  40.  
  41.     }
  42.     @BeforeTest
  43.     public void beforeTest() {
  44.         driver = new FirefoxDriver();
  45.         driver.get("http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx");
  46.         //driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  47.     }
  48.  
  49.     @AfterTest
  50.     public void afterTest() {
  51.         driver.quit();
  52.     }
  53.  
  54. }
');