55from selenium .webdriver .common .by import By
66from selenium .webdriver .firefox .options import Options
77from selenium .webdriver .firefox .service import Service
8- from selenium .webdriver .support import expected_conditions as EC
9- from selenium .webdriver .support .ui import WebDriverWait
10- from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
118
129TAGS = ["wcag2a" , "wcag2aa" , "wcag21aa" ]
1310
@@ -62,9 +59,6 @@ def scan_urls():
6259
6360
6461def create_firefox_driver ():
65- """Create a Firefox WebDriver instance optimized for CI environments"""
66-
67- # Firefox options for CI environment
6862 options = Options ()
6963 options .add_argument ('--headless' )
7064 options .add_argument ('--no-sandbox' )
@@ -73,40 +67,33 @@ def create_firefox_driver():
7367 options .add_argument ('--window-size=1280,1024' )
7468 options .add_argument ('--disable-extensions' )
7569 options .add_argument ('--disable-plugins' )
76- options .add_argument ('--disable-images' ) # Speed up loading
77- options .add_argument ('--disable-javascript' ) # Only if your accessibility scan doesn't need JS
70+ options .add_argument ('--disable-web-security' )
71+ options .add_argument ('--allow-running-insecure-content' )
7872
79- # Set preferences for better CI performance
8073 options .set_preference ('dom.webdriver.enabled' , False )
8174 options .set_preference ('useAutomationExtension' , False )
8275 options .set_preference ('browser.startup.homepage' , 'about:blank' )
8376 options .set_preference ('browser.startup.firstrunSkipped' , True )
8477 options .set_preference ('dom.disable_beforeunload' , True )
78+ options .set_preference ('browser.cache.disk.enable' , False )
79+ options .set_preference ('browser.cache.memory.enable' , False )
80+ options .set_preference ('browser.cache.offline.enable' , False )
81+ options .set_preference ('network.http.use-cache' , False )
82+
83+ options .page_load_strategy = 'normal'
8584
86- # Service configuration
8785 service = Service (
8886 executable_path = '/usr/local/bin/geckodriver' ,
89- log_path = '/tmp/geckodriver.log'
87+ log_output = '/tmp/geckodriver.log'
9088 )
9189
92- # Desired capabilities for additional timeout control
93- caps = DesiredCapabilities .FIREFOX .copy ()
94- caps ['pageLoadStrategy' ] = 'normal' # or 'eager' for faster loading
95- caps ['timeouts' ] = {
96- 'implicit' : 30000 ,
97- 'pageLoad' : 60000 ,
98- 'script' : 30000
99- }
100-
10190 try :
10291 print ("Creating Firefox WebDriver..." )
10392 driver = webdriver .Firefox (
10493 service = service ,
105- options = options ,
106- desired_capabilities = caps
94+ options = options
10795 )
10896
109- # Set additional timeouts
11097 driver .implicitly_wait (30 )
11198 driver .set_page_load_timeout (60 )
11299 driver .set_script_timeout (30 )
@@ -121,8 +108,10 @@ def create_firefox_driver():
121108 with open ('/tmp/geckodriver.log' , 'r' ) as f :
122109 print ("GeckoDriver logs:" )
123110 print (f .read ())
124- except :
125- pass
111+ except FileNotFoundError :
112+ print ("No geckodriver log file found" )
113+ except Exception as log_error :
114+ print (f"Could not read geckodriver log: { log_error } " )
126115 raise
127116
128117
0 commit comments