You are here

public function VarbaseContext::iClickOnTheImageWithTheAltText in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.5

Same name and namespace in other branches
  1. 8.8 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iClickOnTheImageWithTheAltText()
  2. 8.4 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iClickOnTheImageWithTheAltText()
  3. 8.6 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iClickOnTheImageWithTheAltText()
  4. 8.7 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iClickOnTheImageWithTheAltText()
  5. 9.0.x tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iClickOnTheImageWithTheAltText()

#varbase: To click on an image with the provided alt.

Example 1: I click on the image with the "Flag Earth image title" alt text

@Given /^I click on the image with the "([^"]*)" alt text$/

File

tests/features/bootstrap/VarbaseContext.php, line 693

Class

VarbaseContext
Defines application features from the specific context.

Code

public function iClickOnTheImageWithTheAltText($titleText) {

  // Find an image with the title.
  $element = $this
    ->getSession()
    ->getPage()
    ->find('xpath', "//img[contains(@title, '{$altText}')]");
  if (empty($element)) {
    throw new Exception('The page dose not have an image with the [ ' . $altText . ' ] title text.');
  }

  // click on the image.
  $element
    ->click();
}