如何使用 webdriverIO 在网格中搜索特定按钮
How to search an specific button in a grid using webdriverIO
我正在使用 ExtJS 网格面板。这个网格有 20 多行信息,我想在每一行中搜索代表 活动模式 的图标,使用 WebdriverIO 作为测试驱动程序。
如何在每一行中搜索直到测试驱动程序找到第一个活动图标? (注意: 我正在测试的网格托管在 alegra.com 上)。
考虑以下 HTML 打印屏幕:
在不知道您使用的是哪个定位器的情况下很难确切地知道如何做到这一点,但如果您首先获得行列表,然后过滤它们并获取第一个匹配项,它应该可以满足您的需求。
public static get rows() { return browser.elements('#someTableId > table > tbody > tr'); }
public static getFirstMatch() {
return this.rows.value.filter((row: WebdriverIO.Element) =>
browser.elementIdElement(row.ELEMENT, 'someLocator').value)[0];
}
我就是这样做的
var icon_type = 'delete';
it('Se elimina una factura', function(){
//rellenamos el array de elementos del grid
var elements = browser.getAttribute('#gridInvoices #gridview-1047-table tbody tr .action-icons img:nth-child(7)','class');
//Busca la primera coincidencia en el array con type
var row_num = elements.indexOf(icon_type);
if(row_num === -1){
throw new Error('No se encontraron botones activos del tipo "Eliminar" en todo el grid' )
}else{
$$('#gridInvoices #gridview-1047-table tbody tr')[row_num].click('.action-icons [title="Eliminar"]');
browser.click('=Sí')
};
});
我正在使用 ExtJS 网格面板。这个网格有 20 多行信息,我想在每一行中搜索代表 活动模式 的图标,使用 WebdriverIO 作为测试驱动程序。
如何在每一行中搜索直到测试驱动程序找到第一个活动图标? (注意: 我正在测试的网格托管在 alegra.com 上)。
考虑以下 HTML 打印屏幕:
在不知道您使用的是哪个定位器的情况下很难确切地知道如何做到这一点,但如果您首先获得行列表,然后过滤它们并获取第一个匹配项,它应该可以满足您的需求。
public static get rows() { return browser.elements('#someTableId > table > tbody > tr'); }
public static getFirstMatch() {
return this.rows.value.filter((row: WebdriverIO.Element) =>
browser.elementIdElement(row.ELEMENT, 'someLocator').value)[0];
}
我就是这样做的
var icon_type = 'delete';
it('Se elimina una factura', function(){
//rellenamos el array de elementos del grid
var elements = browser.getAttribute('#gridInvoices #gridview-1047-table tbody tr .action-icons img:nth-child(7)','class');
//Busca la primera coincidencia en el array con type
var row_num = elements.indexOf(icon_type);
if(row_num === -1){
throw new Error('No se encontraron botones activos del tipo "Eliminar" en todo el grid' )
}else{
$$('#gridInvoices #gridview-1047-table tbody tr')[row_num].click('.action-icons [title="Eliminar"]');
browser.click('=Sí')
};
});