使用phantomjs进行Odoo测试 - page.evaluate eval结果:false

问题描述 投票:0回答:1

当使用phantomjs测试odoo时(通过定义游览)它会出现错误“page.evaluate eval result:false”并且控制台不断抛出相同的错误:

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

完整代码如下:

test_了噶急哦.朋友

# -*- 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.DEBUG.services ['web.Tour']。run('test_type_invisible','test')时,它会抛出:“TypeError:state is undefined”

当执行odoo.DEBUG.services ['web.Tour']。tours .test_type_invisible它抛出:undefined

那么,发生了什么?它的起源真的是微不足道的。请参阅下面的答案

phantomjs odoo-9
1个回答
0
投票

这里发生的事情基本上是test_legajo.py找不到legajo.tour.js。您必须定义一个.xml文件,告诉odoo legajo.tour.js所在的位置:

按照惯例,它应该被称为“resources.xml”,必须放在views文件夹中,并且必须存在于openerp.py清单中:

folder structure

当odoo找不到包含游览的js文件时,它将继续尝试phantomjs ready =“odoo.DEBUG.services ['web.Tour']。tours .test_type_invisible”,直到失败超时为止。

© www.soinside.com 2019 - 2024. All rights reserved.