protected function DrupalWebTestCase::clickLink
7.x drupal_web_test_case.php | protected DrupalWebTestCase::clickLink($label, $index = 0) |
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 sensitive with normalized space. The label is translated label. There is an assert for successful click.
Parameters
$label: Text between the anchor tags.
$index: Link position counting from zero.
Return value
Page on success, or FALSE on failure.
44 calls to DrupalWebTestCase::clickLink()
- ActionsConfigurationTestCase::testActionConfiguration in drupal-7.x/
modules/ simpletest/ tests/ actions.test - Test the configuration of advanced actions through the administration interface.
- AggregatorTestCase::updateFeedItems in drupal-7.x/
modules/ aggregator/ aggregator.test - Updates the feed items.
- BlockTestCase::testCustomBlock in drupal-7.x/
modules/ block/ block.test - Test creating custom block, moving it to a specific region and then deleting it.
- BlogTestCase::verifyBlogLinks in drupal-7.x/
modules/ blog/ blog.test - Verify the blog links are displayed to the logged in user.
- BookTestCase::testBookExport in drupal-7.x/
modules/ book/ book.test - Tests book export ("printer-friendly version") functionality.
File
- drupal-7.x/
modules/ simpletest/ drupal_web_test_case.php, line 2681
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
Code
protected function clickLink($label, $index = 0) {
$url_before = $this->getUrl();
$urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
if (isset($urls[$index])) {
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
}
$this->assertTrue(isset($urls[$index]), t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), t('Browser'));
if (isset($url_target)) {
return $this->drupalGet($url_target);
}
return FALSE;
}