Posts

Showing posts with the label Webdriver

CSS Selector-How To Locate Parent Element

Answer : 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(".."));

CSS Selector (id Contains Part Of Text)

Answer : Try this: a[id*='Some:Same'][id$='name'] This will get you all a elements with id containing Some:Same and have the id ending in name <div id='element_123_wrapper_text'>My sample DIV</div> The Operator ^ - Match elements that starts with given value div[id^="element_123"] { } The Operator $ - Match elements that ends with given value div[id$="wrapper_text"] { } The Operator * - Match elements that have an attribute containing a given value div[id*="wrapper_text"] { } The only selector I see is a[id$="name"] (all links with id finishing by "name") but it's not as restrictive as it should.