I'm trying to select a country from the country dropDown.
List<WebElement> countryDropDown = driver.findElements(By.xpath(("(//div[@class='uk-dropdown uk-open uk-dropdown-bottom-center']//li")));
WebdriverHelper.selectOptionFromDropDown(countryDropDown, "Spain");
The dropdown opens, the list is displayed, then I receive this message:
Failed to execute 'evaluate' on 'Document': The string '(//div[@class='uk-dropdown uk-open uk-dropdown-bottom-center']//li' is not a valid XPath expression
CodePudding user response:
There are redundant parenthesis there.
Instead of
List<WebElement> countryDropDown = driver.findElements(By.xpath(("(//div[@class='uk-dropdown uk-open uk-dropdown-bottom-center']//li")));
Try this:
List<WebElement> countryDropDown = driver.findElements(By.xpath("//div[@class='uk-dropdown uk-open uk-dropdown-bottom-center']//li"));
