2017-10-11 71 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