javascript - Get class name of the element in selenium web driver java -
i new selenium web driver right facing issue while getting class name of element html of element
<input id="filter-colour-0237739001"><div class="detailbox detailbox-pattern unavailable-colour"><span></span><img src="//lp2.hm.com/hmprod?set=source[/fabric/2014/9b57a69a-fd8d-4d79-9e92-8f5448566c51.jpg],type[fabricswatch]&hmver=0&call=url[file:/product/main]" alt="" title="">
so want extract class name class="detailbox detailbox-pattern unavailable-colour" using selenium web driver. got element below code
webelement ele=driver.findelement(by.id("filter-colour-0237739001"));
now want class can please me on , okay java script also
simply use getattribute()
webelement ele=driver.findelement(by.xpath("//*[@id='filter-colour-0237739001']/../div")); ele.getattribute("class")
edit guess wanted class of div
should using selector pointing div such //*[@id='filter-colour-0237739001']/../div
xpath
Comments
Post a Comment