protected function CommerceWebDriverTestBase::setRawFieldValue in Commerce Core 8.2
Sets an input field's raw value.
HTML5 date and time input elements use locale-specific formats, making it difficult to test across environments. Setting the value via JS allows us to bypass this and modify the underling value, which is always in a consistent format.
Parameters
string $name: The input element name.
string $value: The value.
3 calls to CommerceWebDriverTestBase::setRawFieldValue()
- PromotionTest::testCreatePromotion in modules/
promotion/ tests/ src/ FunctionalJavascript/ PromotionTest.php - Tests creating a promotion.
- PromotionTest::testCreatePromotionWithEndDate in modules/
promotion/ tests/ src/ FunctionalJavascript/ PromotionTest.php - Tests creating a promotion with an end date.
- PromotionTest::testEditPromotion in modules/
promotion/ tests/ src/ FunctionalJavascript/ PromotionTest.php - Tests editing a promotion.
File
- tests/
src/ FunctionalJavascript/ CommerceWebDriverTestBase.php, line 128
Class
- CommerceWebDriverTestBase
- Provides a base class for Commerce functional tests.
Namespace
Drupal\Tests\commerce\FunctionalJavascriptCode
protected function setRawFieldValue($name, $value) {
$this
->getSession()
->executeScript("document.getElementsByName('{$name}')[0].value = '{$value}';");
}