Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebGL is disabled error when opening bing maps with python selenium?

i try to open bing maps using python selenium with this code:

import os, sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

options = Options()
options.add_argument("start-maximized")  
options.add_argument('--use-gl=swiftshader')
options.add_argument('--enable-unsafe-webgpu')
options.add_argument('--enable-unsafe-swiftshader')
options.add_argument("--disable-3d-apis")
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("start-maximized")
options.add_argument('--log-level=3')  
options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})    
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled') 
srv=Service()

baseLink = "https://www.bing.com/maps"
driver = webdriver.Chrome (service=srv, options=options)    
driver.get (baseLink)
input("Press!")

Worked fine for a long time but suddenly i get this error:

enter image description here

How can i open bing maps using python and selenium?

like image 481
Rapid1898 Avatar asked Mar 15 '26 06:03

Rapid1898


1 Answers

Without this option the code works:

# options.add_argument("--disable-3d-apis")

You could try to replace it with:

options.add_argument("--disable-accelerated-2d-canvas")

Prevents fallback to software rendering when GPU is disabled—useful in combination with --disable-gpu.

Also you may consider to add this options:

# Disable pop-ups
options.add_argument("--disable-popup-blocking")

# Disable ads (not guaranteed, but can help)
options.add_argument("--disable-ads")

# Disable notifications
options.add_argument("--disable-notifications")

# Disable extensions (some ads come from extensions)
options.add_argument("--disable-extensions")

Moreover here is the code to click "Reject" by id:
enter image description here

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def click_by_id(id = "bnp_btn_reject", timeout = 10):
    try:
        WebDriverWait(driver, timeout).until(EC.element_to_be_clickable((By.ID, id))).click()
    except Exception as e:
        print(f"Error clicking button: {e}")
click_by_id()

Full code:

import os, sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("start-maximized")  
options.add_argument('--use-gl=swiftshader')
options.add_argument('--enable-unsafe-webgpu')
options.add_argument('--enable-unsafe-swiftshader')
# options.add_argument("--disable-3d-apis") # commented out
options.add_argument("--disable-accelerated-2d-canvas")
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("start-maximized")
options.add_argument('--log-level=3')  
options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})    
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled') 
# New options 
options.add_argument("--disable-popup-blocking")# Disable pop-ups
options.add_argument("--disable-ads")# Disable ads (not guaranteed, but can help)
options.add_argument("--disable-notifications")# Disable notifications
options.add_argument("--disable-extensions")# Disable extensions (some ads come from extensions)


srv=Service()
baseLink = "https://www.bing.com/maps"
driver = webdriver.Chrome (service=srv, options=options)    
driver.get (baseLink)
def click_by_id(id = "bnp_btn_reject", timeout = 10):
    try:
        WebDriverWait(driver, timeout).until(EC.element_to_be_clickable((By.ID, id))).click()
    except Exception as e:
        print(f"Error clicking button: {e}")
click_by_id()

like image 126
Gооd_Mаn Avatar answered Mar 16 '26 21:03

Gооd_Mаn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!