You are here

public function VarbaseContext::iShouldSeeImageWithTheAltTextUnder in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 9.0.x

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

Find an image with the alt text attribute under a custom iframe.

Varbase Context #varbase.

Example 1: Then I should see image with the "Flag Earth" alt text in the rich text editor field "Body"

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

File

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

Class

VarbaseContext
Defines application features from the specific context.

Code

public function iShouldSeeImageWithTheAltTextUnder($altText, $filedName) {

  // Switch to the iframe.
  $iFreamID = $this
    ->getAttributeByOtherAttributeValue('id', 'title', $filedName, 'iframe');
  $this
    ->getSession()
    ->switchToIFrame($iFreamID);

  // 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 under [ ' . $filedName . ' ].');
  }

  // Switch back too the page from the iframe.
  $this
    ->getSession()
    ->switchToIFrame(NULL);
}