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:
Ingo Schommer 2014-06-04 13:24:50 +12:00
commit 0694d4e3a3
1 changed files with 21 additions and 0 deletions

View File

@ -596,6 +596,27 @@ JS;
$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,
* or a named region mapped to a CSS selector via Behat configuration).