admin管理员组文章数量:1312998
I am new to selenium web driver right now i am facing the issue while getting the class name of an element the html of the element look like
<input id="filter-colour-0237739001"><div class="detailbox detailbox-pattern unavailable-colour"><span></span><img src="//lp2.hm/hmprod?set=source[/fabric/2014/9B57A69A-FD8D-4D79-9E92-8F5448566C51.jpg],type[FABRICSWATCH]&hmver=0&call=url[file:/product/main]" alt="" title="">
so i want to extract the class name which is class="detailbox detailbox-pattern unavailable-colour" by using selenium web driver. I got the element by the below code
WebElement ele=driver.findElement(By.id("filter-colour-0237739001"));
now i want the class so can you please help me on this , i am okay with java script also
I am new to selenium web driver right now i am facing the issue while getting the class name of an element the html of the element look like
<input id="filter-colour-0237739001"><div class="detailbox detailbox-pattern unavailable-colour"><span></span><img src="//lp2.hm./hmprod?set=source[/fabric/2014/9B57A69A-FD8D-4D79-9E92-8F5448566C51.jpg],type[FABRICSWATCH]&hmver=0&call=url[file:/product/main]" alt="" title="">
so i want to extract the class name which is class="detailbox detailbox-pattern unavailable-colour" by using selenium web driver. I got the element by the below code
WebElement ele=driver.findElement(By.id("filter-colour-0237739001"));
now i want the class so can you please help me on this , i am okay with java script also
Share Improve this question asked Dec 16, 2014 at 14:26 Prasad MagrePrasad Magre 411 gold badge1 silver badge5 bronze badges1 Answer
Reset to default 5Simply use getAttribute()
WebElement ele=driver.findElement(By.xpath("//*[@id='filter-colour-0237739001']/../div"));
ele.getAttribute("class")
EDIT I guess you wanted the class of div
so you should be using a selector pointing to div such as //*[@id='filter-colour-0237739001']/../div
as xpath
本文标签: javascriptGet class name of the element in selenium web driver javaStack Overflow
版权声明:本文标题:javascript - Get class name of the element in selenium web driver java - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741884371a2402933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论