Skip to content

Commit 1f00d0a

Browse files
committed
[py] Add similar logic to shadowroot and remove relative imports
1 parent bdf892d commit 1f00d0a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

py/selenium/webdriver/remote/shadowroot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
from hashlib import md5 as md5_hash
1919

20-
from ..common.by import By
21-
from .command import Command
20+
from selenium.common.exceptions import InvalidSelectorException
21+
from selenium.webdriver.common.by import By
22+
from selenium.webdriver.remote.command import Command
2223

2324

2425
class ShadowRoot:
@@ -74,6 +75,8 @@ def find_element(self, by: str = By.ID, value: str = None):
7475
by = By.CSS_SELECTOR
7576
value = f'[id="{value}"]'
7677
elif by == By.CLASS_NAME:
78+
if value and any(char.isspace() for char in value.strip()):
79+
raise InvalidSelectorException("Compound class names are not allowed.")
7780
by = By.CSS_SELECTOR
7881
value = f".{value}"
7982
elif by == By.NAME:
@@ -112,6 +115,8 @@ def find_elements(self, by: str = By.ID, value: str = None):
112115
by = By.CSS_SELECTOR
113116
value = f'[id="{value}"]'
114117
elif by == By.CLASS_NAME:
118+
if value and any(char.isspace() for char in value.strip()):
119+
raise InvalidSelectorException("Compound class names are not allowed.")
115120
by = By.CSS_SELECTOR
116121
value = f".{value}"
117122
elif by == By.NAME:

0 commit comments

Comments
 (0)