#How to Block Loading of Images, Media, Stylesheets, and Fonts in SeleniumBase?

1 messages · Page 1 of 1 (latest)

true gust
#

Hi, I’m trying to block the loading of certain resources like images, media files, stylesheets, and fonts while running tests using SeleniumBase. I would like to know the best way to disable these resources to improve test performance or focus on specific elements of the page.

I would appreciate it if someone could provide an example or guide me on how to achieve this for both Chrome browsers using SeleniumBase. Here’s what I’d like to block:

  • Images
  • Media files (e.g., videos, audio)
  • Stylesheets (CSS)
  • Fonts
with SB(uc=True, test=True) as sb:
    sb.uc_open_with_reconnect("https://")
    sb.uc_gui_click_captcha()
    sb.save_screenshot("screenshot.png", selector="body")

Is there a straightforward way to configure these settings in SeleniumBase? Any help or advice would be greatly appreciated. Thank you!

waxen canopy
true gust
#

Okay, thank you!