I’m trying to parse some html using Selenium. The problem is that it raises error in case the class name contains spaces.
Here is the tag I’m searching for: <p class="p0 ng-binding">text</p>
I’ve tried these two options:
JavaScript
x
7
1
result.find_element_by_class_name('departure').find_element_by_css_selector('p.p0 ng-binding').text
2
3
result.find_element_by_class_name('departure').find_element_by_class_name('p0 ng-binding').text
4
5
>>> selenium.common.exceptions.InvalidSelectorException: Message: The given selector p0 ng-binding is either invalid or does not result in a WebElement. The following error occurred:
6
InvalidSelectorError: Compound class names not permitted
7
Could anybody give me a hint?
Advertisement
Answer
The p
element has two classes: p0
and ng-binding
.
Try this selector:
JavaScript
1
2
1
find_element_by_css_selector('p.p0.ng-binding')
2