I tried a simple program to select a language from the drop down in gmail.com page, but it didn't work (it doesn't select the mentioned value from the drop down). Please see the below code:
public class dropdown {
@Test
public void select(){
Keywords app = new Keywords();
app.openBrowser("Mozilla");
app.navigate("url");
app.select("lang", "Filipino");
}
}
Below is the keywords.java file code:
public class Keywords {
Properties prop =null;
WebDriver driver =null;
public Keywords(){
prop = new Properties();
FileInputStream fs;
try {
fs = new FileInputStream("C:\\dipti\\workspace\\Module9\\src\\Test.properties");
prop.load(fs);
} catch (Exception e) {
e.printStackTrace();
}
}
public void openBrowser(String browserType){
ProfilesIni profs = new ProfilesIni();
FirefoxProfile fp = profs.getProfile("sel");
driver = new FirefoxDriver(fp);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
public void navigate(String url){
System.out.println(prop.getProperty(url));
driver.get(prop.getProperty(url));
}
public void select(String xpath, String value){
driver.findElement(By.xpath(prop.getProperty(xpath))).sendKeys(value);
}
}
Below is the properties file code:
url=https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1#identifier
lang=//*[@id='lang-chooser']
use this
Keywords app = new Keywords();
app.openBrowser("Mozilla");
app.navigate("url");
app.select("lang", " ?Filipino? ");