I am using Selenium Webdriver via Java. My method clicks on a filter check box (eg. make, model, etc.), that is passed in, from a modal.
When running my method in my test class, via ChromeDriver, it seems to go pretty slow and rightfully so since I am making a lot of tiny network calls for getText()
. How can I optimize its performance?
public void selectFilter(String filter) {
List<WebElement> filters = driver.findElements(selector.someWebElement());
Map<String, WebElement> mapFilters = new HashMap();
for (int i = 0; i < filters.size(); i++) {
String key = filters.get(i).getText();
WebElement value = filters.get(i).findElement(By.cssSelector("a"));
mapFilters.put(key, value);
}
mapFilters.get(filter).click();
}