public function homepageAlert($alert) { $this->elements['homepageAlert'] = array('xpath' => "//*[//*[@class='messages patient']//*[contains(text(),'{$alert}')]]"); if ($this->getElement('homepageAlert')->isVisible()) { print "Alert Displayed Correctly!"; } else { throw new BehaviorException("Alert not displayed correctly!"); } }