我有一个数据表形式,其中包括几个项目,例如textfield
,datefield
和combobox
。我将如何使用Siesta为combobox
进行选择,并且我需要将Siesta等待时间设置为30000ms以上,因为数据是通过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]'}
最佳答案
最好将此类问题发布到Siesta support forum(由Bryntum开发人员积极监控)。关于Stackoverflow的问题也很受欢迎,但可能会在一段时间内未被注意。
要为Siesta中的所有“ waitFor”方法/操作设置最大等待时间,可以使用waitForTimeout config选项。
要在单击“ groupcombo”后等待Ajax请求完成,可以执行以下操作:
{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()
}
)
这通常简化了测试并且速度更快。
关于testing - 如何通过Bryntum Siesta Test在ExtJS组合框上进行选择?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46685652/