I'm trying to parsing text from this html code using Selenium with python:
<div class=" card card_selected" data-id="3248846777">
<p>Hello World!</p>
</div>
I use this code:
my_class = " card card_selected"
live_deal = browser.find_element_by_class_name(my_class)
I get this error :
selenium.common.exceptions.InvalidSelectorException: Message: Given css selector expression ". card card_selected" is invalid: InvalidSelectorError: '. card card_selected' is not a valid selector: ". card card_selected"
This error happen when the class name start with spaces.
how can I handle this error ?