1

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 ?

1 Answer 1

9

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

Sign up to request clarification or add additional context in comments.

5 Comments

ty so much Christine.. now i know how to deal with it
well there's alot of problem in this website not just javascript codes .. is there any way to disable that javascript error from showing in console ?
In Selenium, I am not sure if that's possible. The real solution is to have the website not run Javascript that is broken. There aren't any Selenium solutions unless you disable Javascript completely, which will probably break the page under test.
Finaly!! .. "--log-level=3" this parameter solved the problem for me >>> 'Sets the minimum log level. Valid values are from 0 to 3: INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3. <<< i set it to 3 so it passes the warnings and errors ^_^
Good one! I'll add it to the answer in case others need to see it in the future too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.