I need to select an element in a dropdown window. Every time I open the dropdown window in the site I am testing, the website randomly generates an id for that dropdown window.
java.util.List<WebElement> elements = driver.findElements(By.xpath("//div[@class='really long name for drop down menu']/ul/li[2]"));
elements[elements.count - 1].click();
That should click the last element with that particular class.