public function TestSubContext::assertNotRegionElementTextAttribute in Panopoly 8.2
Same name and namespace in other branches
- 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::assertNotRegionElementTextAttribute()
Tests for element content and attributes in region.
@Then I should not see :text in the :tag element with the :attribute attribute set to :value in the :region region
File
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 778 - Provide Behat step-definitions for generic Panopoly tests.
Class
- TestSubContext
- Behat sub-context for Panopoly.
Code
public function assertNotRegionElementTextAttribute($text, $tag, $attribute, $value, $region) {
$regionObj = $this
->getRegion($region);
$elements = $regionObj
->findAll('css', $tag);
if (!empty($elements)) {
foreach ($elements as $element) {
if ($element
->getText() == $text) {
$attr = $element
->getAttribute($attribute);
if (!empty($attr) && strpos($attr, "{$value}") !== FALSE) {
throw new \Exception(sprintf('The text "%s" was found in the "%s" element with the "%s" attribute set to "%s" in the "%s" region on the page %s', $text, $tag, $attribute, $value, $region, $this
->getSession()
->getCurrentUrl()));
}
}
}
}
}