You are here

public function ElementContext::assertEmptyElement in Lightning Core 8

Same name and namespace in other branches
  1. 8.5 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::assertEmptyElement()
  2. 8.2 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::assertEmptyElement()
  3. 8.3 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::assertEmptyElement()
  4. 8.4 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::assertEmptyElement()

Asserts that an element is empty.

@Then the :selector element(s) should be empty

Parameters

string $selector: The element's CSS selector.

Throws

ExpectationException If the element contains any HTML (leading and trailing white space is trimmed out).

File

tests/contexts/ElementContext.behat.inc, line 29

Class

ElementContext
Contains miscellaneous step definitions for working with HTML elements.

Namespace

Acquia\LightningExtension\Context

Code

public function assertEmptyElement($selector) {
  $content = $this
    ->assertSession()
    ->elementExists('css', $selector)
    ->getHtml();
  if (trim($content)) {
    throw new ExpectationException("Expected element '{$selector}' to be empty, but it is not.", $this
      ->getSession()
      ->getDriver());
  }
}