Below is my code and html code, please let me know how to compare values. When i executed i am getting same result (Mateched) for multiple times. But i want to compare and display result as "Matched" (Only for one time).
public class Ex1 {
private WebDriver d;
@Test
public void testUntitled() throws Exception {
d = new FirefoxDriver();
d.get("http://register.rediff.com/commonreg/index.php?redr=http://portfolio.rediff.com/money/jsp/loginnew.jsp?redr=home");
String[] exp = {"Month", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
WebElement dropdown = d.findElement(By.id("date_mon"));
Select select = new Select(dropdown);
List<WebElement> options = select.getOptions();
for(WebElement we:options)
{
for (int i=0; i<exp.length; i++){
if (we.getText().equals(exp[i])){
System.out.println("Matched");
}
}
} }}
Output:
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Mateched
Html:
select id="date_mon" onfocus="validateSignupForm(3)" name="date_mon">
<option value="">Month</option>
<option value="01">JAN</option>
<option value="02">FEB</option>
<option value="03">MAR</option>
<option value="04">APR</option>
<option value="05">MAY</option>
<option value="06">JUN</option>
<option value="07">JUL</option>
<option value="08">AUG</option>
<option value="09">SEP</option>
<option value="10">OCT</option>
<option value="11">NOV</option>
<option value="12">DEC</option>