I am trying the following code that is supposed to add the extension adblock to the driver
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
def navigate_to_url(url):
options = Options()
options.add_argument('start-maximized')
options.add_extension('adblock.crx')
options.add_experimental_option('detach', True)
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get(url)
return driver
if __name__ == '__main__':
driver = navigate_to_url('https://www.google.com')
print(driver.current_url)
The code is working and the extension is already there but there is a new tab opened by the adblock extension. How can I prevent such page to be opened automatically?
I have created this but I welcome any other ideas or solutions