【问题标题】:Selenium Python Script Printing ErrorsSelenium Python 脚本打印错误
【发布时间】:2020-10-20 09:15:19
【问题描述】:

我想知道是否有任何方法可以隐藏从控制台生成的“未捕获的 SecuriyError。我相信错误消息是由网站提供的,但我不确定。我的程序按预期工作,但它只是在运行时不断出现错误消息,这很烦人。作为旁注,我在 PYCharm 中运行时没有看到任何这些错误。

任何帮助都会很棒!谢谢!

34 out of 37 completed
[0630/015306.733:INFO:CONSOLE(11)] 
"Uncaught SecurityError: Blocked a frame 
with origin "https://ws2.osfi-bsif.gc.ca" 
from accessing a frame with origin 
"https://www.osfi-bsif.gc.ca". Protocols, 
domains, and ports must match.", source: 
https://ws2.osfi- 
bsif.gc.ca/WebApps/FINDAT/DTIBanks.aspx? 
T=0&LANG=E (11)
[0630/015307.079:INFO:CONSOLE(11)] 
"Uncaught SecurityError: Blocked a frame 

【问题讨论】:

    标签: python selenium iframe console


    【解决方案1】:

    看看https://stackoverflow.com/a/63625977/1387701

    """get log entreies from selenium and add to python logger before returning"""
    loglevels = { 'NOTSET':0 , 'DEBUG':10 ,'INFO': 20 , 'WARNING':30, 'ERROR':40, 'SEVERE':40, 'CRITICAL':50}
    
    #initialise a logger
    browserlog = logging.getLogger("chrome")
    #get browser logs
    slurped_logs = driver.get_log('browser')
    for entry in slurped_logs:
        #convert broswer log to python log format
        rec = browserlog.makeRecord("%s.%s"%(browserlog.name,entry['source']),loglevels.get(entry['level']),'.',0,entry['message'],None,None)
        rec.created = entry['timestamp'] /1000 # log using original timestamp.. us -> ms
        try:
            #add browser log to python log
            browserlog.handle(rec)
        except:
            print(entry)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多