2017-10-11 69 views
1

我有一个数据表格,包括几个项目,如textfield,datefieldcombobox。如何使用Siesta为combobox制作选择项,我需要将Siesta的等待时间设置为30000ms以上,因为数据通过ajax请求加载到combobox如何使用Bryntum Siesta测试在ExtJS组合框上进行选择?

有一个我已经使用过的代码段失败了,

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]'} 

回答

2

其最好的发布此类问题Siesta support forum(这是积极Bryntum开发者监测)。关于Stackoverflow的问题也很受欢迎,但可能在一段时间内未被注意。

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

要等待Ajax请求完成你点击了“groupcombo”你可以这样做后:

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

注意,但是,有一个潜在的竞争条件在此代码(描述here

另外,请注意,在设置某些字段的值时,您实际上正在验证其他核心业务逻辑,它们将这些字段关联在一起。因此,有没有严格的需要进行实际的输入/点击,你可以直接设置字段的值:

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() 
    } 
) 

这往往简化了测试的速度要快得多。

+0

亲爱的@SamuraiJack我用't.cq1','setValue'方法使用链; '函数(下一个)t.cq1('typecombo [xtype = typecombo]')。setValue('GOO') next() }'但是当我运行测试时,它选择了组合内部的值。但接受测试通过:| –

+0

对,“setValue”是一个Ext字段类的方法,它不会在测试中创建任何断言。 – SamuraiJack

相关问题