You are here

protected function NodequeueWebTestCase::clickImage in Nodequeue 7.2

Same name and namespace in other branches
  1. 6.2 tests/nodequeue.test \NodequeueWebTestCase::clickImage()

Follows an image link by alt or title text.

Index behavior is the same as clickLink()'s.

Parameters

$label: Text between the anchor tags.

int $index: Link position counting from zero.

Return value

bool Page on success, or FALSE on failure.

File

tests/nodequeue.test, line 26
Tests for the Nodequeue module.

Class

NodequeueWebTestCase
Class with common helper methods.

Code

protected function clickImage($label, $index = 0) {
  $url_before = $this
    ->getUrl();
  $urls = $this
    ->xpath('//img[@title="' . $label . '"]/ancestor::a|//img[@alt="' . $label . '"]/ancestor::a');
  if (isset($urls[$index])) {
    $url_target = $this
      ->getAbsoluteUrl($urls[$index]['href']);
  }
  $this
    ->assertTrue(isset($urls[$index]), t('Clicked image link "!label" (!url_target) from !url_before', array(
    '!label' => $label,
    '!url_target' => $url_target,
    '!url_before' => $url_before,
  )), t('Browser'));
  if (isset($urls[$index])) {
    return $this
      ->drupalGet($url_target);
  }
  return FALSE;
}