You are here

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

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

Find an image with the alt text attribute.

Varbase Context #varbase.

Example 1: Then I should see image with the "Flag Earth" alt text.

@Then /^I should see image with the "([^"]*)" alt text$/

File

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

Class

VarbaseContext
Defines application features from the specific context.

Code

public function iShouldSeeImageWithTheAltText($altText) {

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