protected function ThunderFormFieldTestTrait::setCheckbox in Thunder 6.1.x
Same name and namespace in other branches
- 8.5 tests/src/FunctionalJavascript/ThunderFormFieldTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderFormFieldTestTrait::setCheckbox()
- 8.2 tests/src/FunctionalJavascript/ThunderFormFieldTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderFormFieldTestTrait::setCheckbox()
- 8.3 tests/src/FunctionalJavascript/ThunderFormFieldTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderFormFieldTestTrait::setCheckbox()
- 8.4 tests/src/FunctionalJavascript/ThunderFormFieldTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderFormFieldTestTrait::setCheckbox()
- 6.2.x tests/src/FunctionalJavascript/ThunderFormFieldTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderFormFieldTestTrait::setCheckbox()
- 6.0.x tests/src/FunctionalJavascript/ThunderFormFieldTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderFormFieldTestTrait::setCheckbox()
Set value for group of checkboxes.
Existing selection will be cleared before new values are applied.
Parameters
\Behat\Mink\Element\DocumentElement $page: Current active page.
string $fieldName: Field name.
string $value: Comma separated values for checkboxes.
1 call to ThunderFormFieldTestTrait::setCheckbox()
- ThunderFormFieldTestTrait::setFieldValue in tests/
src/ FunctionalJavascript/ ThunderFormFieldTestTrait.php - Set value for defined field name on current page.
File
- tests/
src/ FunctionalJavascript/ ThunderFormFieldTestTrait.php, line 26
Class
- ThunderFormFieldTestTrait
- Trait for manipulation of form fields.
Namespace
Drupal\Tests\thunder\FunctionalJavascriptCode
protected function setCheckbox(DocumentElement $page, $fieldName, $value) {
// UnCheck all checkboxes and check defined.
$this
->getSession()
->executeScript("jQuery('input[name*=\"{$fieldName}\"]').prop('checked', false);");
$checkNames = explode(',', $value);
foreach ($checkNames as $checkName) {
$checkBoxName = $fieldName . '[' . trim($checkName) . ']';
$this
->scrollElementInView('[name="' . $checkBoxName . '"]');
$page
->checkField($checkBoxName);
}
}