mercredi 30 décembre 2020

How to select multiple checkboxes in Dusk test

I am using VueJS with bootstrap-vue, and using Laravel Dusk, I need to test a table inside a modal that uses a checkbox to select each row. In this particular case, there are multiple rows with checkboxes, and I need to select all of the checkboxes in the form and then submit the form. My test works fine with the modal in every way except checking the checkboxes; no matter what I try, I can't get the check() (or click()) method to check more than the first one. I've tried

->check("input[type=checkbox]")

and using the name

->check("input[name='my-custom-name']")

but I still only get the first item checked. Based on this, I tried something like

$checkboxes = $browser->driver->findElements(WebDriverBy::name('select-pursuit-restore[]'));
for ($i = 0; $i <= count($checkboxes); $i++) {
    $checkboxes[0]->click();
}

but even that only checks the first checkbox. What do I need to do to select all of the checkboxes in the table?




Aucun commentaire:

Enregistrer un commentaire