Getting image SRC with xpath - Simpletest (WebTestBase) I am developing a Drupal 8 test which will check for a image's existence. The image will not be loaded while running the test and I want to catch that using xpath().

The HTML I am trying to search is,

&lt;ul aria-labelledby="ckeditor-toolbar-group-aria-label-for-media" data-drupal-ckeditor-button-sorting="target" role="toolbar" class="ckeditor-buttons ckeditor-toolbar-group-buttons ui-sortable"&gt;
  &lt;li class="ckeditor-button" data-drupal-ckeditor-button-name="Blockquote"&gt;
  &lt;a aria-label="blockquote" title="blockquote" role="button" class="cke-icon-only cke_ltr" href="#"&gt;&lt;span class="cke_button_icon cke_button__blockquote_icon"&gt;blockquote&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li class="ckeditor-button" data-drupal-ckeditor-button-name="DrupalImage"&gt;
    &lt;a aria-label="Image" title="Image" role="button" href="#"&gt;
      &lt;span class="cke_button_icon"&gt;
        &lt;img title="Image" alt="" src="http://local/"&gt;
      &lt;/span&gt;
    &lt;/a&gt;
  &lt;/li&gt;
&lt;/ul&gt;


In this HTML you can see that I need to find the SRC in the  tag. The SRC is invalid and it should be http://local/test.png. I am searching the HTML with $this-&gt;xpath('//span[@class="cke_button_icon"]/img[@src]'); but getting a blank array in return. 
How can I fetch this element?
Perhaps you could try the following XPath: //span[@class="cke_button_icon"]/img/@src.