How can I select the second value from a list item that appears as a drop-down on a web page? In this case, the second value is 'Bellevue'. Refer to the screenshot below:
I am implementing Page Objects and trying to locate elements using @FindBy annotations. Here is my attempted solution:
@FindBy(how=How.CSS,using = "a[id^='ui-id-'][1]")
However, I encountered the following error:
The given selector a[id*='ui-id-'](1) is either invalid or does not result in a WebElement
Alternatively, when I tried:
@FindBy(how=How.CSS,using = "a[id^='ui-id-']"[1])`
I received the error:
the type of expression must be an array but it resolved to string`.
I managed to make it work by using the following code:
WebElement value = driver.findElements(By.cssSelector("a[id^='ui-id']")).get(3);
value.click();
However, I need to implement @FindBy
and have been unsuccessful with the get(3) method.