Is there a way to avoid loading certain elements in selenium? For example, as defined by an XPATH expression?
My goal is to avoid loading CAPTCHAs, which take an enormous amount of time to load, but which I do not need to solve or bypass. The goal is not to hide the element, but to avoid the network latency associated with loading the CAPTCHA, which is 10 times the page itself.
I'm happy using selenium-wire to intercept requests if that is the necessary solution.
AFAIK this is not supported by Selenium.
Actually you are asking: how to prevent a web page from loading some / several web elements on it with Selenium.
Selenium is actually used to mimic real user's actions performed via the GUI.
So user can click element, grab it's text, scroll the page etc. But regular user is not able to avoid web page from loading some elements on the page like CAPTCHA.
Especially the issue is with CAPTCHA. It is developed against automated tools like Selenium. So you can not bypass it and not prevent loading it with Selenium.
Avoid fetching certain element in Selenium - like a custom ad blocker