CSS Selector-How to locate Parent Element

Referring to the Is there a CSS parent selector? topic, there is no parent selector in CSS. Leave the "getting the parent" part to the XPath:

WebElement we = dr.findElement(By.cssSelector("div[id='gf-BIG']"));
WebElement parent = we.findElement(By.xpath(".."));

If it would help here is example how get it by xpath

WebElement parentElement = driver.findElement(By.xpath("//div[@id='gf-BIG']/parent::parentElementTag"));

parentElementTag - could be div/span/tr - depends on your case


If the parent is say div, you could try something like below

div div[id='gf-BIG']