JAVA - How to use xpath in selenium JAVA - How to use xpath in selenium selenium selenium

JAVA - How to use xpath in selenium


You don't have your XPath syntax right. You need quotes round the text attribute values you're matching against. Try:

d.findElement(By.xpath("//select[@id='category']/option[@id='cat2']")).click();