public function VarbaseContext::iShouldSeeImageWithTheTitleTextInTheRichTextEditorField in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8
Same name and namespace in other branches
- 8.4 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iShouldSeeImageWithTheTitleTextInTheRichTextEditorField()
- 8.5 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iShouldSeeImageWithTheTitleTextInTheRichTextEditorField()
- 8.6 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iShouldSeeImageWithTheTitleTextInTheRichTextEditorField()
- 8.7 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iShouldSeeImageWithTheTitleTextInTheRichTextEditorField()
- 9.0.x tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iShouldSeeImageWithTheTitleTextInTheRichTextEditorField()
Find an image with the title text attribute under a custom iframe.
Varbase Context #varbase.
Example 1: Then I should see image with the "Flag Earth" title text in the rich text editor field "Body"
@Then /^I should see image with the "([^"]*)" title text in the rich text editor field "([^"]*)"$/
File
- tests/
features/ bootstrap/ VarbaseContext.php, line 792
Class
- VarbaseContext
- Defines application features from the specific context.
Code
public function iShouldSeeImageWithTheTitleTextInTheRichTextEditorField($titleText, $locator) {
$el = $this
->getSession()
->getPage()
->findField($locator);
$fieldId = $el
->getAttribute('id');
if (empty($fieldId)) {
throw new \Exception('Could not find an id for the rich text editor field : ' . $locator);
}
$this
->getSession()
->executeScript("return CKEDITOR.instances[\"{$fieldId}\"].getData();");
// Switch to the iframe.
$iFreamID = $this
->getAttributeByOtherAttributeValue('id', 'title', $fieldId, 'iframe');
$this
->getSession()
->switchToIFrame($iFreamID);
// Find an image with the title.
$element = $this
->getSession()
->getPage()
->findAll('xpath', "//img[contains(@title, '{$titleText}')]");
if (empty($element)) {
throw new \Exception('The page dose not have an image with the [ ' . $titleText . ' ] title text under [ ' . $locator . ' ].');
}
// Switch back too the page from the iframe.
$this
->getSession()
->switchToIFrame(NULL);
}