Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

finding element by classname and tagname using selenium webdriver

Tags:

java

selenium

There are classes and tagname and I am writing the below selenium code to find description from below code but its not working.

WebElement WWdescription = driver.findElement(By.className("atb-delivery-accordions").className("section highlight-01").tagName("p"));    


<div class="atb-delivery-accordions">
    <div class="page-accordion opened">
    <input id="moreDetails-acc" class="acc-check" type="checkbox" checked="">
    <label class="acc-label opened" data-panel-id="moreDetailsAcc" for="moreDetails-acc">Description</label>
    <div class="content" data-panel-id="moreDetailsAcc" style="display: block;">
    <div class="information-panel">
    <div class="subcontent">
    <div class="section highlight-01">
    <p>A pretty floral lace collection combining contrast bows and trims for a feminine on trend look. The fuller coverage of our post surgery bras provide support, comfort and confidence. The dual cotton pockets are perfect for a prosthesis. Combine style and value with this pack of 2 bras.</p>
like image 737
Pankaj Sharma Avatar asked Aug 12 '15 11:08

Pankaj Sharma


1 Answers

Try something like this:

 WebElement parentEle = driver.findElement(By.xpath("//div[@class='atb-delivery-accordions']"));

 WebElement descriptionEle = parentEle.findElement(By.tagName("p"));

 //Get the text from the description element.
 String descriptionText = descriptionEle.getText();
like image 185
Saritha G Avatar answered Oct 23 '22 03:10

Saritha G