Created
August 17, 2013 05:01
-
-
Save delphian/6255353 to your computer and use it in GitHub Desktop.
Determine if a Mink NodeElement contains a specific css rule attribute value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine if a Mink NodeElement contains a specific css rule attribute value. | |
* | |
* @param NodeElement $element | |
* NodeElement previously selected with $this->getSession()->getPage()->find(). | |
* @param string $rule | |
* Name of the CSS rule, such as "visibility". | |
* @param string $value | |
* Value of the specified rule, such as "hidden". | |
* | |
* @return NodeElement|bool | |
* The NodeElement selected if true, FALSE otherwise. | |
*/ | |
protected function elementHasCSSValue($element, $rule, $value) | |
{ | |
$exists = FALSE; | |
$style = $element->getAttribute('style'); | |
if ($style) { | |
if (preg_match("/(^{$rule}:|; {$rule}:) ([a-z0-9]+);/i", $style, $matches)) { | |
$found = array_pop($matches); | |
if ($found == $value) { | |
$exists = $element; | |
} | |
} | |
} | |
return $exists; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment