Skip to content Skip to sidebar Skip to footer

How To Search An Specific Button In A Grid Using Webdriverio

I'm using an ExtJS grid panel. This grid has more than 20 rows of info and I want to search in each row for an icon that represents active mode, using WebdriverIO as a test driver.

Solution 1:

It's hard to know exactly how to do it without knowing which locator you are using but if you first get a list of the rows and then filter them and grab the first match it should do what you are looking for.

publicstaticgetrows() { return browser.elements('#someTableId > table > tbody > tr'); }

publicstaticgetFirstMatch() {
    returnthis.rows.value.filter((row: WebdriverIO.Element) =>
        browser.elementIdElement(row.ELEMENT, 'someLocator').value)[0];
}

Solution 2:

This is how i did it

var icon_type = 'delete';

it('Se elimina una factura', function(){        
        //rellenamos el array de elementos del gridvar elements = browser.getAttribute('#gridInvoices #gridview-1047-table tbody tr .action-icons img:nth-child(7)','class');
        //Busca la primera coincidencia en el array con typevar row_num = elements.indexOf(icon_type);

    if(row_num === -1){
        thrownewError('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í')
        };  
});

Post a Comment for "How To Search An Specific Button In A Grid Using Webdriverio"