mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Merge pull request #39 from srizzling/pulls/fill-in-field-region
Adding support to fill in field in a specfic region
This commit is contained in:
commit
0694d4e3a3
@ -596,6 +596,27 @@ JS;
|
|||||||
$linkObj->click();
|
$linkObj->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fills in a field in a specfic region similar to (@see iFollowInTheRegion or @see iSeeTextInRegion)
|
||||||
|
*
|
||||||
|
* Example: Given I fill in "Hello" with "World"
|
||||||
|
*
|
||||||
|
* @Given /^I fill in "(?P<field>[^"]*)" with "(?P<value>[^"]*)" in the "(?P<region>[^"]*)" region$/
|
||||||
|
*/
|
||||||
|
public function iFillinTheRegion($field, $value, $region){
|
||||||
|
$context = $this->getMainContext();
|
||||||
|
$regionObj = $context->getRegionObj($region);
|
||||||
|
assertNotNull($regionObj, "Region Object is null");
|
||||||
|
|
||||||
|
$fieldObj = $regionObj->findField($field);
|
||||||
|
if (empty($fieldObj)) {
|
||||||
|
throw new \Exception(sprintf('The field "%s" was not found in the region "%s" on the page %s', $field, $region, $this->getSession()->getCurrentUrl()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$regionObj->fillField($field, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts text in a specific region (an element identified by a CSS selector, a "data-title" attribute,
|
* Asserts text in a specific region (an element identified by a CSS selector, a "data-title" attribute,
|
||||||
* or a named region mapped to a CSS selector via Behat configuration).
|
* or a named region mapped to a CSS selector via Behat configuration).
|
||||||
|
Loading…
Reference in New Issue
Block a user