Tuesday, 5 August 2014

Printing the drop down values without using 'Select' class&Hidden vales of drop down

driver.get("http://www.facebook.com");
  // This will return 13 webelemenst
     List<WebElement> l1= driver.findElements(By.xpath("//*[@id='month']/option"));
      // Now using we will iterate using iterator
        Iterator<WebElement> i1=l1.iterator();      
        while(i1.hasNext()){      
        // Here we are capturing text using getText
        String value=i1.next().getText();      
        System.out.println(value);
=====+++++++++++++=====OR
 String e=driver.findElement(By.xpath("//*[@id='splitterid']")).getText();
System.out.println(e);

+++++++++++++++
wd.get("http://jqueryui.com/autocomplete/#combobox"); 
wait.until(ExpectedConditions.visibilityOf(wd.findElement(By.xpath(".//*[@id='content']/iframe")))); 
wd.switchTo().frame(wd.findElement(By.xpath(".//*[@id='content']/iframe"))); 
wd.findElement(By.cssSelector(".ui-button.ui-widget.ui-state-default.ui-button-icon-only.custom-combobox-toggle.ui-corner-right")).click();

WebElement combobox = wd.findElement(By.id("combobox")); 
List<WebElement> options = new Select(combobox).getOptions(); 
for (WebElement webElement : options) 

System.out.println("> " + webElement.getAttribute("value")); 


++++++++++++++++++++drop down desabled text++++++++
WebDriverWait wait = new WebDriverWait(driver, 60);
System.out.println("Waiting for Select"); 
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='shipping-info']/div/form/div[1]/div/div[2]/div[3]/div/div[4]/div[2]/div/div/a"))); 
Thread.sleep(10000); 
System.out.println("Selecting State"); 
driver.findElement(By.xpath("//*[@id='shipping-info']/div/form/div[1]/div/div[2]/div[3]/div/div[4]/div[2]/div/div/a")).click(); 
Thread.sleep(10000); 
action.sendKeys("California").build().perform(); 
Thread.sleep(500); 

action.sendKeys(Keys.TAB).build().perform();