summaryrefslogtreecommitdiffstatshomepage
path: root/core/tests/Drupal
diff options
context:
space:
mode:
Diffstat (limited to 'core/tests/Drupal')
-rw-r--r--core/tests/Drupal/Tests/BrowserTestBase.php5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 457e22286f4..12228dbea72 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -609,9 +609,8 @@ abstract class BrowserTestBase extends TestCase {
* The JSON decoded drupalSettings value from the current page.
*/
protected function getDrupalSettings() {
- $html = $this->getSession()->getPage()->getContent();
- if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $html, $matches)) {
- $settings = Json::decode($matches[1]);
+ if ($elements = $this->xpath('//script[@type="application/json" and @data-drupal-selector="drupal-settings-json"]')) {
+ $settings = Json::decode($elements[0]->getText());
if (isset($settings['ajaxPageState']['libraries'])) {
$settings['ajaxPageState']['libraries'] = UrlHelper::uncompressQueryParameter($settings['ajaxPageState']['libraries']);
}