Reputation: 147
Visit this link
I want to get the product material & care
details.
Shell: 70% polyester, 30% wool
Lining: 100% polyester
Dry-clean.
I have tried below mentioned code, but it does not work for me.
self.browser.find_element_by_xpath("//h6[@class='pdp-product-description-title']/p").text
Upvotes: 1
Views: 67
Reputation: 2611
Try this way.
Explanation of xpath:- Start xpath
with <h6>
tag along with text
method and then move ahead with <p>
tag using following
keyword.
self.browser.find_element_by_xpath("//h6[contains(text(), 'Material & Care')]/following::p[@class='pdp-product-description-content']").text
OR
Use Indexing with <p>
tag.
self.browser.find_element_by_xpath("//h6[contains(text(), 'Material & Care')]/following::p[1]").text
Upvotes: 1
Reputation: 50949
The <p>
tag is a sibling, not a child element. Use following-sibling::p
self.browser.find_element_by_xpath("//h6[@class='pdp-product-description-title']/following-sibling::p").text
Upvotes: 1