Skip to content

Commit 994f9df

Browse files
committed
Another update to the xpath-to-css converter
1 parent 56cf4aa commit 994f9df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

seleniumbase/fixtures/xpath_to_css.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ def convert_xpath_to_css(xpath):
172172
if xpath[0] != '"' and xpath[-1] != '"' and xpath.count('"') % 2 == 0:
173173
xpath = _handle_brackets_in_strings(xpath)
174174
xpath = xpath.replace("descendant-or-self::*/", "descORself/")
175+
if len(xpath) > 3:
176+
xpath = xpath[0:3] + xpath[3:].replace('//', '/descORself/')
175177

176178
if " and contains(@" in xpath and xpath.count(" and contains(@") == 1:
177179
spot1 = xpath.find(" and contains(@")
@@ -211,7 +213,9 @@ def convert_xpath_to_css(xpath):
211213
css = css.replace(" descORself > ", ' ')
212214
css = css.replace("/descORself/*", ' ')
213215
css = css.replace("/descORself/", ' ')
216+
css = css.replace("descORself > ", '')
214217
css = css.replace("descORself/", ' ')
218+
css = css.replace("descORself", ' ')
215219
css = css.replace("_STAR_=", "*=")
216220
css = css.replace("]/", "] ")
217221
css = css.replace("] *[", "] > [")

0 commit comments

Comments
 (0)