python - Python Usign Selenium 的明显错误:PosixPath 的问题
问题描述
晚上好,我已经开始了一个 django 项目,使用 python 3.7 和 Django 3.1.5 当我启动我的单一测试时,它们运行得很好。运行硒时,这就是我得到的:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/test/testcases.py", line 1322, in __call__
return super().__call__(environ, start_response)
File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
response = self.get_response(request)
File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/test/testcases.py", line 1305, in get_response
return self.serve(request)
File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/test/testcases.py", line 1317, in serve
return serve(request, final_rel_path, document_root=self.get_base_dir())
File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/views/static.py", line 36, in serve
fullpath = Path(safe_join(document_root, path))
File "/Users/fabricejaouen/Documents/OC_Parcours_Python/advocacy_project/venv/lib/python3.7/site-packages/django/utils/_os.py", line 17, in safe_join
final_path = abspath(join(base, *paths))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/posixpath.py", line 80, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
它的奇怪部分是:
- 没有引发与我的项目相关的错误,
- Selenium 测试完美通过,这是我的 Selenium 设置:
from django.test import LiveServerTestCase
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver import Firefox
import os
class CustomUserTest(LiveServerTestCase):
fixtures = ['users.json']
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.browser = Firefox()
cls.browser.implicitly_wait(10)
@classmethod
def tearDownClass(cls):
cls.browser.quit()
super().tearDownClass()
def test_plaid_10_authenticate_on_the_website(self):
"""
The user wants to authenticate in order to have access to
the functionalities of the website
"""
self.browser.get(os.path.join(self.live_server_url, ''))
因此,我可以继续我的项目,但是,这个令人费解的问题困扰着我。如果你们中的任何人有提示,我会非常高兴。亲切的问候。
解决方案
这就是重点。添加:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
我的设置解决了这个问题。谢谢。
推荐阅读
- r - 在闪亮的不工作中部署 R 程序
- php - 碳逐月获得数字回报三月 2
- java - Pivotal GemFire 多会话的 Spring 会话
- powershell - 网格中的多行
- laravel - Laravel 5.6 队列重启 CPU 使用率
- python-requests - Python - 更改请求参数,使其不以“?=”和“&”开头
- angular6 - 当我在获取带有订阅的数据后调度操作时的无限循环
- c# - 如何比较两个属性组合的两个列表并选择第三个属性不匹配的行?
- json - 我怎样才能解决这个问题?从“[String]”转换为不相关类型“[String : AnyObject]”总是失败
- python - 有上限误差的上限