我有一个Django项目,其中有一些前端依赖项,因此我尝试添加django-bower来帮助我管理它们。
我已将以前的依赖关系替换为Bower版本,并且一切似乎都正常进行。我正在使用Selenium进行测试,当我在本地运行它们时,它们正在通过。
但是,当我继续在CI服务器上进行测试时,Selenium测试失败,并显示一条错误消息,即它无法在页面上找到元素。这是一个表单元素,我确定它在那里。
我试图找出为什么测试在本地通过但在CI服务器上失败的原因。在添加django-bower之前,所有测试也在CI服务器中通过。
这是Django设置中相关部分的摘录
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
# Compressor finder
"compressor.finders.CompressorFinder",
# Django bower finder
"djangobower.finders.BowerFinder",
)
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = '/uploads/'
BOWER_COMPONENTS_ROOT = os.path.join(BASE_DIR, 'static', 'js')
BOWER_INSTALLED_APPS = (
'fontawesome#4.3.0',
'jquery-validation#1.13.1',
'magnific-popup#1.0.0',
'masonry#3.2.2',
'materialize#0.95.3',
)
凉亭组件安装在 static/js/bower_components
CI服务器上提供的错误消息是
NoSuchElementException: Message: {"errorMessage":"Unable to find element with id 'message-form'","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"93","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:60555","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","method":"POST","post":"{\"using\": \"id\", \"sessionId\": \"bb17c920-c5dd-11e4-9c9b-e7fbd91dc2da\", \"value\": \"message-form\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/bb17c920-c5dd-11e4-9c9b-e7fbd91dc2da/element"}}
任何帮助将不胜感激。我已经搜索了所有我能想到的并且似乎找不到解决方案的内容。
我将Bower用于Django项目,但未使用django-bower。我可以单独使用它(通过bower install
),让它在静态/增强组件中存储前端deps,并使用{% static %}
template标签在模板中引用该路径。不知道这样做是否会影响您奇怪的测试结果,但值得一试。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句