I have a website with the following code snippet:
<div class="list_item_normal">
<div class="main_content">
<div class="img_wrap">
<a href="/home/Detaljer/9781118093757"><img alt="Miniaturebillede af omslaget til Operating System Concepts" src="/images/product_thumb/9781/118/093/9781118093757.jpg?1354045210" title="Miniaturebillede af omslaget til Operating System Concepts" /></a>
</div>
<div class="data_wrap">
<h4>
<!-- Added by sathiyaraj regarding E-book integration CR -->
<a href="/home/Detaljer/9781118093757">Operating System Concepts</a> <small style='background-color:yellow;'></small>
</h4>
<h5>
Abraham Silberschatz and Peter B. Galvin
(2013)
</h5>
<div class="imprint">
John Wiley & Sons, Limited
</div>
<div class="price">
610,00 kr.
</div>
</div>
</div>
I am struggling to retrieve the content enclosed within the h5 tag. Despite my efforts, I am unable to achieve this. Here is the current piece of code I have been working on for the past 30 minutes:
content = driver.findElement(By.xpath("//div[contains(@class, 'content')]"));
List<WebElement> list
= content.findElements(
By.xpath("//div[contains(@class, 'list_item_normal')]"));
System.out.println(list.size()); // Just for debugging purposes
for (WebElement e : list) {
System.out.println(e.findElement(By.xpath("//h5")).getText());
}
driver.close();
}
This pertains to a book store where the author's name is found within the h5 tag. However, executing the above code yields a list of 10 identical authors, even though they are different in reality. I am unsure of where I am going wrong.
Could you please advise me on how to properly extract data from that specific tag?
EDIT:
You can view the entire page HTML here: http://pastebin.com/QALCvtaG