How do i fetch the name "JAFFERYI ADI" from the following html code? Have to fetch the name within for loop every time name will be different only the word 'years' will be common. I tried with
"driver.findElement(By.xpath("//div[@class='patient-slide-header']/div[contains(text(), 'years')]"
but found NoSUchELementException. Please help. Here is the html DOM
<div class="patient-slide-header" style="" xpath="1">
<div class="patient-slide-header patient-slide-header-h2" style="">
<a onclick="objPatientDetail.NavigatePatient('backward');" href="#" class="prev-patient patient-details-navigation" style=""></a>
JAFFERYI ADI (56 years)
<div class="patient-slide-header-details"></div>
<a onclick="objPatientDetail.NavigatePatient('forward');" class="next-patient patient-details-navigation" href="#" style=""></a>
<input type="hidden" id="hdnHIEurl">
</div>