Selenium - Find child under DIV
Can someone help me with below HTML:
<div id="ext-156" class="menuBar"> <a id="ext-234" href="javascript:void(0);" class="active"> <i id="ext-365" class="menuItem"></i> </a> </div> I am looking for an element with class "menuItem" and only from within a div with class "menuBar" in Selenium.
+5
2 answers
Well, depending on which language you use, the method call will be different, but the selector must be the same for the language binding:
CSS
"div.menuBar .menuItem" xpath:
"//div[@class='menuBar']//*[@class='menuItem']" In java, the call would look like this:
driver.find(By.cssSelector("div.menuBar .menuItem")); +6