1

我有一个数据表表单,其中包括几个项目,例如textfielddatefieldcombobox。我将如何使用 Siesta 进行选择项,combobox并且我需要将 Siesta 等待时间设置为超过 30000 毫秒,因为数据是通过ajax请求加载到combobox.

我使用的一个片段失败了;

t.it('Should create a new registration', function (t) {
        t.chain(
            {click: '>> button[text=New]'},
            {waitForCQ: 'regdata[title=New Registration]'},
            {click: '>> firstnamefld[xtype=firstnamefld]'},
            {type: 'Siesta Reg', target: '>> firstnamefld[xtype=firstnamefld]'},
            {click: '>> lastnamefld[xtype=lastnamefld]'},
            {type: 'Test One', target: '>> lastnamefld[xtype=lastnamefld]'},
            {click: '>> datefld[xtype=datefld]'},
            {type: '11.10.2017', target: '>> checkinfld[xtype=checkinfld]'}, //Probably that's not correct way to choose date on datefield but it works

//Here is making ajax request to load data in combo.but Siesta isn't waiting for selection.
//I shouldn't use 'type' for this part but I couldn't find any proper property.
                {click: '>> groupcombo[xtype=groupcombo]'},
                {type: 'Group One', target: '>> groupcombo[xtype=groupcombo]'}
4

1 回答 1

2

最好将此类问题发布到Siesta 支持论坛(由 Bryntum 开发人员积极监控)。Stackoverflow 上的问题也很受欢迎,但可能会在一段时间内被忽视。

要为 Siesta 中的所有“waitFor”方法/操作设置最长等待时间,您可以使用waitForTimeout配置选项。

单击“groupcombo”后,要等待 Ajax 请求完成,您可以执行以下操作:

{click: '>> groupcombo[xtype=groupcombo]'},
{
    waitFor : function () {
        if (someConditionThatIsTrueOnceAjaxRequestHasCompleted) return true
    }
},
{type: 'Group One', target: '>> groupcombo[xtype=groupcombo]'}

但是请注意,此代码中存在潜在的竞争条件(在此处描述)

另外,请注意,在设置某些字段的值时,您实际上是在验证其他一些将这些字段联系在一起的核心业务逻辑。因此,不需要执行实际的键入/单击,您可以直接设置字段的值:

t.chain(
    function (next) {
        t.cq1('compqueryselector1').setValue('someValue1')
        t.cq1('compqueryselector2').setValue('someValue2')
        next()
    },
    function (next) {
        t.pass(businessLogicIsCorrect(), "Business logic rules works")
        next()
    }
)

这通常简化了测试并且速度更快。

于 2017-10-11T11:23:22.750 回答