1

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

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

Does my explanation of code helped you? If it does then please mark this answer as Accepted if it's resolved your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.