function DrupalTestCase::clickLink in SimpleTest 6
Same name and namespace in other branches
- 5 drupal_test_case.php \DrupalTestCase::clickLink()
Follows a link by name.
Will click the first link found with this link text by default, or a later one if an index is given. Match is case insensitive with normalized space. The label is translated label. There is an assert for successful click. WARNING: Assertion fails on empty ("") output from the clicked link
Parameters
string $label Text between the anchor tags.: @param integer $index Link position counting from zero. @param boolean $reporting Assertions or not @return boolean/string Page on success.
@access public
4 calls to DrupalTestCase::clickLink()
File
- ./
drupal_test_case.php, line 229
Class
- DrupalTestCase
- Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.
Code
function clickLink($label, $index = 0) {
$url_before = $this
->getUrl();
$urls = $this->_browser->_page
->getUrlsByLabel($label);
if (count($urls) < $index + 1) {
$url_target = 'URL NOT FOUND!';
}
else {
$url_target = $urls[$index]
->asString();
}
$ret = parent::clickLink(t($label), $index);
$this
->assertTrue($ret, ' [browser] clicked link ' . t($label) . " ({$url_target}) from {$url_before}");
return $ret;
}