i'm creating a desktop application with selenium and python.. this app gets some data from my website with selenium .. it works fine without any problems untill i tried to run chrome in headless mode .. like that:
opt = Options()
opt.add_argument("--headless")
cpanel_window = webdriver.Chrome("chromedriver.exe", options=opt)
cpanel_window.get(mywebsite)
it works fine but in the console there are werid messages appear after sometime..
[1016/142332.539:INFO:CONSOLE(2)] "Uncaught TypeError: Cannot read property 'left' of null", source: https://eaalim.examhelper.org/js/lavalamp.js (2)
[1016/142337.343:INFO:CONSOLE(0)] "Mixed Content: The page at 'https://eaalim.examhelper.org/cpanel/SendInvoice_1To1.aspx?coursecode=SB22496&back_sid=8969&back_g=All&back_type=s' was loaded over HTTPS, but requested an insecure image 'http://eaalim.examhelper.org/emailtemplates/responsive/images/Icon-responsive.png'. This content should also be served over HTTPS.", source: https://eaalim.examhelper.org/cpanel/fckeditor/editor/fckeditor.html?InstanceName=ctl00%24ContentPlaceHolder3%24txtemail&Toolbar=Default (0)
[1016/142337.344:INFO:CONSOLE(0)] "Mixed Content: The page at 'https://eaalim.examhelper.org/cpanel/SendInvoice_1To1.aspx?coursecode=SB22496&back_sid=8969&back_g=All&back_type=s' was loaded over HTTPS, but requested an insecure image 'http://eaalim.examhelper.org/emailtemplates/responsive/images/logo.png'. This content should also be served over HTTPS.", source: https://eaalim.examhelper.org/cpanel/fckeditor/editor/fckeditor.html?InstanceName=ctl00%24ContentPlaceHolder3%24txtemail&Toolbar=Default
the application doesn't stop but those messages are really annoying because i print the steps and reports in console so i need it clean.. is there any way to avoid or hide those messages ?
You might need to add a few additional Options
to Chromedriver to bypass the warnings.
For headless mode, I also add --disable-gpu
and --window-size=1920,1200
to set the proper window size for my tests -- if the browser is too small, elements will render differently. --disable-gpu
is recommended by chromedriver devs here.
You may also want to add --no-sandbox
and --allow-insecure-localhost
to help with the HTTPS errors you are seeing.
Added by the original asker: To hide the Javascript warnings you are seeing, you can set --log-level=3