繁体   English   中英

selenium python 中无头 chrome 上的控制台警告和错误

[英]console warrnings and errors on headless chrome in selenium python

我正在使用seleniumpython创建一个桌面应用程序 .. 这个应用程序使用 selenium 从我的网站获取一些数据 .. 它工作正常,没有任何问题,直到我尝试在无头模式下运行

opt = Options()
opt.add_argument("--headless")
cpanel_window = webdriver.Chrome("chromedriver.exe", options=opt)
cpanel_window.get(mywebsite)

它工作正常,但在控制台中,一段时间后会出现奇怪的消息..

[1016/142332.539:INFO:CONSOLE(2)]“未捕获的类型错误:无法读取 null 的属性‘left’”,来源: 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

应用程序不会停止,但这些消息真的很烦人,因为我在控制台中打印步骤和报告,所以我需要它干净.. 有什么方法可以避免或隐藏这些消息?

您可能需要向 Chromedriver 添加一些额外的Options来绕过警告。

对于无头模式,我还添加--disable-gpu--window-size=1920,1200来为我的测试设置正确的 window 大小——如果浏览器太小,元素将呈现不同。 --disable-gpu是 chromedriver devs 推荐

您可能还想添加--no-sandbox--allow-insecure-localhost来帮助解决您看到的 HTTPS 错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM