Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python selenium脚本完成后,Flask会话将立即退出_Python_Selenium_Flask_Selenium Webdriver_Google Chrome Headless - Fatal编程技术网

Python selenium脚本完成后,Flask会话将立即退出

Python selenium脚本完成后,Flask会话将立即退出,python,selenium,flask,selenium-webdriver,google-chrome-headless,Python,Selenium,Flask,Selenium Webdriver,Google Chrome Headless,因此,我在单击值后调用函数run_脚本 @app.route('/results', methods=['GET', 'POST']) def result_page(): url = "https://www.google.com" auto_ui.open_headless(url) # passing url to open_headless function, of auto_ui.py module result = auto.run_scr

因此,我在单击值后调用函数run_脚本

@app.route('/results', methods=['GET', 'POST'])
def result_page():
    url = "https://www.google.com"
    auto_ui.open_headless(url) # passing url to open_headless function, of auto_ui.py module
    result = auto.run_script() # this will run all steps and return "pass" or "fail" string
    return render_template('result.html', header = result)
在整个脚本运行完毕后,我的日志将被生成,屏幕截图也将被捕获。所以我确信,脚本已经运行了。我试图通过results.html显示这些结果

但问题是,, 在我的flask应用程序运行后,selenium devtools也开始运行:

 * Serving Flask app 'main' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
INFO:werkzeug: * Running on http://localhost:8080/ (Press CTRL+C to quit)
INFO:werkzeug:127.0.0.1 - - [31/May/2021 12:34:44] "GET / HTTP/1.1" 200 -                       " 200 -
INFO:werkzeug:127.0.0.1 - - [31/May/2021 12:34:45] "GET /static/css/materialize.min.css HTTP/1.1" 200 -
                                                                                                
DevTools listening on ws://127.0.0.1:50124/devtools/browser/509c447d-58e5-42fc-a10d-6cb447e734f9
PS D:\
问题是:在整个脚本运行后,我的flask应用程序会自动退出。 是因为selenium脚本正在关闭它吗?
是否有办法举行烧瓶会话

我没有足够的重新填充来发表评论

您可以尝试使会话永久化:

app.config['SESSION_PERMANENT'] = True

是否使用
driver.quit()
driver.close()
关闭浏览器会话?我认为这应该关闭浏览器实例。没有,但事实证明这是由于在创建截图pdf和传回文件名时发生了一些异常。我们将找出错误并发布它。