Selecting option from hidden select dropdown | Selenium Forum
M
Posted on 29/01/2017
[attachment=0:1rr5gp6c]Hidden select_not able to select value in dropdown.docx[/attachment:1rr5gp6c]Dropdown on Salesforce.com site have hidden Select tag and no option in HTML tag is visibly displayed.

Not able to select values from dropdown using Select Class methods or even sendKeys() function.

Refer attachment and provide solution on what code needs to be used to select values in such dropdown.

M
Replied on 29/01/2017

you have sent me the wrong screenshot. you're not using the select statement in screenshot.


M
Replied on 29/01/2017

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;

public class exercise1 {

public static void main(String[] args) throws InterruptedException {

WebDriver d = new FirefoxDriver();
d.manage().window().maximize();
d.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

d.navigate().to("https://www.salesforce.com/in/form/signup/freetrial-sales.jsp?d=70130000000Ysa5");

d.findElement(By.xpath("//*[@id='UserFirstName']")).sendKeys("FM");
d.findElement(By.xpath("//*[@id='UserLastName']")).sendKeys("LM");
d.findElement(By.xpath("//*[@id='form-container']/ul/li[10]/div/div[2]/a/span[1]")).click();
List<WebElement>dropdownvalues=d.findElements(By.tagName("a"));
String value="IT Manager";

for(WebElement allvalues:dropdownvalues){
System.out.println(allvalues.getText());
if(allvalues.getText().trim().toLowerCase().equalsIgnoreCase(value.trim().toLowerCase())){
allvalues.click();
break;
}



}