使用phantomjs进行Odoo测试-page.evaluate评估结果:false
使用phantomjs测试odoo时(通过定义tours),它会出现一个错误“page.evaluate eval result:false”,console会不断抛出相同的错误:使用phantomjs进行Odoo测试-page.evaluate评估结果:false,phantomjs,odoo-9,Phantomjs,Odoo 9,使用phantomjs测试odoo时(通过定义tours),它会出现一个错误“page.evaluate eval result:false”,console会不断抛出相同的错误: 2018-09-10 13:46:12,250 8311 INFO grp openerp.tests.common: phantomjs: PhantomTest.run: wait for condition: odoo.__DEBUG__.services['web.Tour'].tours.test_type
2018-09-10 13:46:12,250 8311 INFO grp openerp.tests.common: phantomjs: PhantomTest.run: wait for condition: odoo.__DEBUG__.services['web.Tour'].tours.test_type_invisible
2018-09-10 13:46:12,251 8311 INFO grp openerp.tests.common: phantomjs: page.evaluate eval expr: odoo.__DEBUG__.services['web.Tour'].tours.test_type_invisible
2018-09-10 13:46:12,252 8311 INFO grp openerp.tests.common: phantomjs: page.evaluate eval result: false
完成代码如下:
测试_legajo.py
# -*- coding: utf-8 -*-
from openerp.tests import common
class TestsLegajo(common.HttpCase):
"""
tests models uy_hr.legajo
Requires:
-PhantomJS
"""
MENU_ID = 'uy_hr.uy_hr_legajos_menu'
post_install = True
at_install = False
def setUp(self):
super(TestsLegajo, self).setUp()
self.authenticate('admin', 'admin1234')
self._build_URL()
def _build_URL(self):
ir_ui_menu = self.env.ref(self.MENU_ID)
act_window = ir_ui_menu.action
modelo = act_window.res_model
menuId = ir_ui_menu.id
actId = act_window.id
self.url = '/web#model=%s&menu_id=%s&action=%s&' % (modelo, menuId, actId)
def test_type_invisible(self):
"""
Verifica campo type no aparezca en la vista form
"""
self.phantom_js(
url_path=self.url,
code="odoo.__DEBUG__.services['web.Tour'].run('test_type_invisible', 'test')",
ready="odoo.__DEBUG__.services['web.Tour'].tours.test_type_invisible",
login=None
)
legajo.tour.js
odoo.define('legajo.tour', function(require) {
'use strict';
var core = require('web.core');
var Tour = require('web.Tour');
var _t = core._t;
Tour.register({
id: 'test_type_invisible',
name: _t("Verifica campo type no aparezca en la vista form"),
mode: 'test',
steps: [
{
title: _t("1 - Paso Dummy (Carga de Página)."),
waitFor: 'button.o_list_button_add',
},
{
title: _t("2 - Se accede al formulario de creación de Solicitud de Recursos."),
waitFor: "button.o_list_button_add",
element: "button.o_list_button_add",
},
{
title: _t("3 - Verifica campo type no aparezca en la vista form"),
waitFor: "label.oe_form_label.o_form_invisible:contains('Tipo')",
},
]
});
});
执行odoo时。调试.services['web.Tour']。在浏览器控制台中手动运行('test_type_invisible','test'),它会抛出:
“TypeError:状态未定义”
执行odoo时。调试.services['web.Tour'].tours.test\u type\u抛出不可见:
未定义
那么,发生了什么?它的起源实在微不足道。请看下面我的答案这里发生的事情基本上是test_legajo.py找不到legajo.tour.js。 您必须定义一个.xml文件,告诉odoo legajo.tour.js的位置: 按照惯例,它应该被称为“resources.xml”,必须放在views文件夹中,并且必须出现在openerp中。py清单:
当odoo找不到包含tours的js文件时,它将继续尝试phantomjs ready=“odoo.DEBUG.services['web.Tour'].tours.test_type_invisible”,直到超时失败为止。如果答案有效,您可以接受自己的答案。这样一来,它就不会以未答复的形式出现在列表中,但它让我等了2天,这很奇怪。我猜你找不到自己的快速答案。我猜Stack想给一些时间来找到更好的答案,或者如果不合适的话,可能会禁止我的答案。。。在任何情况下,18个小时去jaja