/** * @Given /^I follow "([^"]*)" for the query "([^"]*)"$/ */ public function iFollowForTheQuery($linkText, $cssQuery) { $items = $this->getPage()->findAll('css', $cssQuery); $didFindIt = false; $link = null; $linkTextLower = strtolower($linkText); $whatWeFound = array(); foreach ($items as $item) { $attr = $this->getAttributesFromElement($item); $whatWeFound[] = $attr; if ($this->isSubstringInArray($attr, $linkTextLower)) { $didFindIt = true; $link = $item; break; } } WebTestCase::assertTrue($didFindIt, 'Could not find the link'); WebTestCase::assertNotNull($link, 'Could not find the link'); $link->click(); }