CSS selector. How to find the parent element
Is there a way to find the parent element in the CSS Selector? I am using below code but I am not getting the parent.
WebElement we=dr.findElement(By.cssSelector("div[id='gf-BIG']:parent"));
I know there is a way in XPath, but please let me know how we can find the parent in the CSS Selector.
+3
source to share
2 answers
Referring to Is there a CSS parent selector? , there is no parent selector in CSS. Leave the "get parent" part in XPath:
WebElement we = dr.findElement(By.cssSelector("div[id='gf-BIG']"));
WebElement parent = we.findElement(By.xpath(".."));
+10
source to share