florentbr / SeleniumBasic

A Selenium based browser automation framework for VB.Net, VBA and VBScript
BSD 3-Clause "New" or "Revised" License
431 stars 197 forks source link

load page without image #188

Open Waker-fr opened 5 years ago

Waker-fr commented 5 years ago

Hello,

In order to run my code faster, I would like to know how to load pages without images. I think I can do that with Driver.SetPreference but I can't figure how I am supposed to do.

I found many things in python like chromeOptions = webdriver.ChromeOptions() prefs = {'profile.managed_default_content_settings.images':2} chromeOptions.add_experimental_option("prefs", prefs) driver = webdriver.Chrome(chrome_options=chromeOptions) but I don't know how to translate it in VBA

Maybe the solution is to go trough a chrome profile but I can't figure out how too.

mogulman52 commented 5 years ago

When SeleniumBasic runs by default it creates a new instance of browser with a new profile. You can force it to use an existing profile.

Dim drv As Selenium.WebDriver
Dim drvChrome As ChromeDriver
Set drvChrome = New ChromeDriver
Set drv = drvChrome
drv.SetProfile "MyProfile", persistant:=True

You can manually change this profile to not load images.