I am trying to loop list A and compare each element in list A to list B looking for a match I can’t figure out why this while loop is only executing once?
for (WebElement webElement : inputs)
{
if (webElement.getAttribute("type").equalsIgnoreCase("text"))
{
String element = webElement.getAttribute("id").toString();
System.out.println("Element: " + element);
while(e.hasMoreElements())
{
String param = (String) e.nextElement();
System.out.println("Parameter: " + param);
System.out.println(element.matches(param));
if(element.matches(param))
{
webElement.sendKeys(vars.get(param));
//inputs.remove(element);
}
}
}
}
Sorry here is the rest of the code, is referenced before the code above
Hashtable vars = new Hashtable();
vars.put("USERNAME","slider");
vars.put("POSTCODE","LU1 3LU");
vars.put("EMAIL","david.cunningham@lumesse.com");
vars.put("DOB","02 Mar 1983");
Enumeration<String> e = vars.keys();
My guess is that you’ve got something like:
outside the for loop. You need to put it inside the for loop, before the
whileloop. Otherwise you’re iterating all the the way through it, but never going back to the start.(I’d also advise you to use the
Iterable/Iteratorinterfaces if you possibly can, and generic collections.)