I have a following line of code:
<div class="topText">Text</div>
And i want to get "Text" from it as String variable MyText
I have tried to use this:
MyText = driver.find_element_by_xpath("string(//div[@class='topText'])")
But it gives me an error: Message: invalid selector: Unable to locate an element with the xpath expression string(//div[@class='topText_1SWFA']) because of the following error: TypeError: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type.
I have also tried simple Xpath like:
MyText = driver.find_element_by_xpath("//div[@class='topText_1SWFA']/text()")
or another alternatives but it doesn't work either