Adding support to fill in field in a specfic region

This commit is contained in:
Sriram Venkatesh 2014-05-07 16:07:21 +12:00
parent 10da00c796
commit 5e58444e07
1 changed files with 21 additions and 0 deletions

View File

@ -584,6 +584,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).