Skip to content

Commit 2d787e0

Browse files
committed
Fix xpath-to-css selector conversion
1 parent 8cf2648 commit 2d787e0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

seleniumbase/fixtures/xpath_to_css.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,17 @@ def convert_xpath_to_css(xpath):
206206
if xpath.startswith("("):
207207
xpath = _filter_xpath_grouping(xpath)
208208

209-
css = _get_raw_css_from_xpath(xpath)
209+
css = ""
210+
if "/descORself/" in xpath and ("@id" in xpath or "@class" in xpath):
211+
css_sections = []
212+
xpath_sections = xpath.split("/descORself/")
213+
for xpath_section in xpath_sections:
214+
if not xpath_section.startswith("//"):
215+
xpath_section = "//" + xpath_section
216+
css_sections.append(_get_raw_css_from_xpath(xpath_section))
217+
css = "/descORself/".join(css_sections)
218+
else:
219+
css = _get_raw_css_from_xpath(xpath)
210220

211221
attribute_defs = re.findall(r"(\[\w+\=\S+\])", css)
212222
for attr_def in attribute_defs:

0 commit comments

Comments
 (0)