Answer the question
In order to leave comments, you need to log in
How to get text from an element using selenium webdriver?
Hello. There is this piece of html: pastebin.com/YcvyHe09
I need text from span: <span class="hover-only">ilen ivory</span>
But only text that has class="selected" in this div:
<div class="item selected sole-ii" data-sku="MS-S-II">
driver.find_element_by_xpath("//div[@id='soleColorBadges']/div[@class='item selected']/label/div/div[@class='sole-description']/span").text
Answer the question
In order to leave comments, you need to log in
Perhaps you are not specifying the xpath correctly. I would recommend using chrome tools. You can use "CSS-style" to search the DOM.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question