seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.46k stars 910 forks source link

Error "Unable to convert XPath Selector to CSS Selector" in seleniumbase 4.25.0 #2658

Closed uendelbatista closed 3 months ago

uendelbatista commented 3 months ago

Hello, when trying to use the xpath below in the recently released version, the error "Unable to convert XPath Selector to CSS Selector" is returning. I reinstalled version 4.24.12 and everything worked again

xpath_bet = f"(//span[(text()='Arsenal') or (text()='Luton')]/ancestor-or-self::div[@class='_3-Kwf']//button)[1]"

driver.uc_click(xpath_bet , by="xpath")
mdmintz commented 3 months ago

That's a long & messy XPath you have there. Might not even be valid, and even if it was somehow, it would need a CSS equivalent because uc_click() requires JS, which needs selectors to be in CSS Selector format. Use a CSS Selector instead, or a valid XPath that has a CSS Selector equivalent. Not all XPaths can be directly translated into matching CSS Selectors, but all elements can be expressed via CSS Selector, so just give it a CSS Selector directly instead.

uendelbatista commented 3 months ago

Thank you very much for the quick response @mdmintz