I
I
Igor2015-08-25 18:25:57
Python
Igor, 2015-08-25 18:25:57

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">

Here's what I sketched, but this option does not work:
driver.find_element_by_xpath("//div[@id='soleColorBadges']/div[@class='item selected']/label/div/div[@class='sole-description']/span").text

Help solve the problem :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Palamarchuk, 2015-08-25
@delef

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 question

Ask a Question

731 491 924 answers to any question